trap {
write-host "Error connecting to $computer" -fore red "$computer" | out-file c:\demo\errors.txt -append
continue
}
$computer = "localhost"
get-wmiobject win32_operatingsystem -comp $computer -ErrorAction stop
$computer = "server2"
get-wmiobject win32_operatingsystem -comp $computer -ErrorAction stop
$computer = "localhost"
get-wmiobject win32_operatingsystem -comp $computer -ErrorAction stop