Get the AD computers that are running windows server 2008 edition

$Servers = Get-ADComputer -filter * -Properties name,operatingsystem | where operatingsystem -like ‘*2008*’
#$servers
foreach ($Servername in $servers){
if (Test-Connection $servername.name -Count 1 -Quiet){
Get-ADComputer $servername -Properties name,operatingsystem | select name,operatingsystem | Export-Csv c:\2008_Servers_Online.csv -Append
}
else {
$servername | select name | Export-Csv c:\2008_Servers_OFFline.csv -Append
}
}

Leave a Reply

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