$ErrorActionPreference = "Stop"
Get-ADComputer -Filter * -Property OperatingSystemVersion,Name | where {$_.OperatingSystemVersion -like "*5.2*"} | select-object Name | export-csv -delimiter "`t" -path c:\scripts\2003sq.txt
get-content c:\scripts\2003sq.txt |
select-string -pattern 'Name' -notmatch |
select-string -pattern '----' -notmatch |
select-string -pattern '#TYPE Selected.Microsoft.ActiveDirectory.Management.ADComputer' -notmatch |
% {$_ -replace '"', ""} |
out-file c:\scripts\2003s.txt
$2003 = get-content c:\scripts\2003s.txt
foreach ($comp in $2003)
{
try
{
test-connection -ComputerName $comp -count 1
}
catch
{
"$comp appears inactive"
}
}
Very helpful if you only want a list of your servers.
Thanks ! - PSkiller 9 years ago