Posted in
Windows Powershell,
Windows Server |
No Comment | 1,938 views | 18/08/2013 00:25
You can check Windows Server 2012 version with following script:
1
2
3
4
5
6
7
8
9
10
11
12
| $Servers = Get-Content "C:\Servers.txt"
foreach ($Server in $Servers)
{
Write-Host "--------------------"
Write-Host $Server
$Version = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Server).Version
Write-Host $Version
if ($Version -like "6.2*")
{
Add-Content -Value $Server -Path C:\Windows2012Servers.txt
}
} |
$Servers = Get-Content "C:\Servers.txt"
foreach ($Server in $Servers)
{
Write-Host "--------------------"
Write-Host $Server
$Version = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Server).Version
Write-Host $Version
if ($Version -like "6.2*")
{
Add-Content -Value $Server -Path C:\Windows2012Servers.txt
}
}
That will output all results into Windows2012Servers.txt file.