#I am new to powershell # Trying to get memory usage information of few servers. I was able to get the result for few servers and not for few others(i get “RPC server unavailable” error) I’m guessing that’s a firewall issue and i’m ok with that but i need the list of servers that the command failed to run. I tried to run below “script” with no luck.
$x = get-content .\abc.txt foreach($a in $x) { $wmi = gwmi -class win32_operatingsystem -computername $a -errorvariable err } if ($err -gt 0) { write-host"$y" }
I got the information that i need by comparing the result that i have got and the original text file. But trying to know the better way to trap the error