Get the Powershell version from all the servers of a Domain

Get-ADComputer -Filter { OperatingSystem -Like ‘*Windows Server*’} |
foreach-object{
Invoke-Command -ComputerName $_.name -ScriptBlock {
$p = $PSVersionTable.PSVersion
$h = HOSTNAME
if (($p -eq ‘2.0’) -or ($p -eq ‘3.0’) -or ($p -eq ‘4.0’)){
write-host $h”  –>  powershell Version: “$p -BackgroundColor Red
}
else {
write-host $h”  –>  powershell Version: “$p

}
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *