Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Add -ErrorAction SilentlyContinue to your command.

When it is not an error but an unhandled exception, you should add -EV Err -EA "SilentlyContinue" In order to catch the exception. (EA is an alias for ErrorAction)

You can then evaluate the error in your script by having a look at $Err[0]

share|improve this answer
I'm afraid that doesnt work unless I'm sticking it in the wrong place. get-process -ComputerName server1, server2, server3 -name explorer -ErrorAction SilentlyContinue | Select-Object processname,machinename – Jake Nov 30 '11 at 11:53
Add it to get-process or take a look at my updated answer above. – Bart De Vos Nov 30 '11 at 12:04

Short answer: Add $ErrorActionPreference = 'Continue' at the start of your code so you don't need to add -ErrorAction SilentlyContinue to every command

Long answer: See

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.