Archive for the ‘CMD’ Category

Simple PowerShell Script To Retrieve Data From DataBase

As im continuing posts on PowerShell scripts . This post to demonistrate how to connect to sqlserver and retrieve data from DataBase. $connString = "data source=.;Initial catalog=Production;uid=sa;pwd=uer_password;" $QueryText = "select * from TableName" $SqlConnection = new-object System.Data.SqlClient.SqlConnection $SqlConnection.ConnectionString = $connString $SqlCommand = $SqlConnection.CreateCommand() $SqlCommand.CommandText = $QueryText $DataAdapter = new-object System.Data.SqlClient.SqlDataAdapter $SqlCommand $dataset = new-object System.Data.Dataset […]

More »

Powershell rename all files in a folder

Avery hard question to ask How to rename all files in folder ? And the answer is very simple use Powershell I will make a simple code to get all files in the folder and search for word or pattern in the name And change the name of the file . $Files = get-childitem -path […]

More »

Replacing Strings in Multiple Files in Folder and SubFolders

This is the second article on windows PowerShell scripting . Now what we want to do ? Simply we want to replace certain string by another string value in all files in certain folder and All sub folders . $items = Get-ChildItem * -recurse # enumerate the items array foreach ($item in $items) {   […]

More »

“Robocopy” Robust File and Folder Copy.

I faced in my work that they want to make Backup for my project processed files. “Backup issue for large number of files” and has avery huge size . Let me describe my case. I have source directory that is about 2 TB and the destination has already a lot of this file , So […]

More »