Tuesday, 6 March 2012

PowerShell






The day was ending as usual  and before I leaved I have to move 500 servers to OU. At beginning I thought it will take 15 to 20 min using the script and will leave the day as usual.
I have used the bulk move script to move the servers to the OU, Hiccups started when the server are falling to move and to verify the list of server fail to move out of 500 servers will take more 2 hours to investigate.

 
Thought of using vlookup function in excel but it is not always show the result as excepted and then what next – Will powershell serve the need and the answer is YES.

 
Here are the steps how I did it…

 
There are two input file as.txt and ansi.txt
as.txt is the file that has been used in bulk move and ansi.txt is the list of all server in the OU after the bulk move.







PS C:\Users\Administrator> Compare-Object $(Get-Content C:\Users\Administrator\Desktop\as.txt) $(Get-Content C:\Users\Administrator\Desktop\ansi.txt) -includeequal Where-Object { $_.SideIndicator -like '<=' }

 
InputObject SideIndicator

 
----------- -------------

 
100 <=
 


..Love

Born as Mathematician, Found love in Scripting and want to have an affair with C#

Total Pageviews