Monday, April 11, 2011

Script of Getting OS Version using Powershell

Powershell makes it easy to get information from remote servers.

Below is the query to find OS Version of all the remote servers you are connected with-

Step1- Create the list of all the servers in a notepad with name "serverlist.txt". I have saved this file on location "D:\Powershell" you can change it with your own location.

Step2- Execute below script-

PS C:\Windows\system32>$serverlist = Get-Content "D:\Powershell\serverlist.txt"
PS C:\Windows\system32>foreach($server in $serverlist)
$serverversion = Get-WmiObject -computer $server -cl Win32_OperatingSystem
write-output $server, $serverversion.version | out-file "D:\Powershell\OSVersion.txt" -append

You can also save the script in a notepad and save it with extension ".ps1". When you will execute the file OS Version for all the servers in the server list will store in the OSVersion file.


  1. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.


  2. First time I commented in a blog! I really enjoy it. You have an awesome post. Please do more articles like this. I'm gonna come back surely. God bless.