How to ignore an error in Powershell and let it continue?
Posted
by
Jake
on Server Fault
See other posts from Server Fault
or by Jake
Published on 2011-11-30T08:32:07Z
Indexed on
2011/11/30
10:02 UTC
Read the original article
Hit count: 267
powershell
I am trying to see if a process is running on multiple servers and then format it into a table.
get-process -ComputerName server1,server2,server3 -name explorer | Select-Object processname,machinename
Thats the easy part - When the process does not exist or if the server is unavailable, powershell outputs a big ugly error, messes up the the table and doesn't continue. Example
Get-Process : Couldn't connect to remote machine.At line:1 char:12 + get-process <<<< -ComputerName server1,server2,server3 -name explorer | format-table processname,machinename
+ CategoryInfo : NotSpecified: (:) [Get-Process], InvalidOperatio nException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power Shell.Commands.GetProcessCommand
How do I get around this? If the I would still like to get notified if the process isn't available or Running.
© Server Fault or respective owner