This script will pull from a list of workstations in a text file and report back the OS and Service  Pack Level across 
the network, it will need to be run with appropriate priviledges to succeed

PowerShell
Edit|Remove
##  http://blog.getbusinessconfident.com
##  This script will pull from a list of workstations in a text file and report back the OS and Service ##  Pack Level across 
##  the network, it will need to be run with appropriate priviledges to succeed



$erroractionpreference = “SilentlyContinue”

$servers = gc servers.txt

foreach ($server in $servers)
{

$testconn = test-path “\\$server\c$”

if ($testconn -match “false”)
{
write-host “Can’t connect to:” $server
}
if ($testconn -match “true”)
{
#write-host “Server:” $server
$os = gwmi win32_operatingsystem -computer $server
$sp = $os | % {$_.servicepackmajorversion}
$a = $os | % {$_.caption}

write-host $server “:” “|” “Operating System:” $a “Service Pack:” “|” $sp

}

}

#end script