http://community.idera.com/powershell/powertips/b/tips/posts/minimalistic-error-handling
# suppress errors by default $ErrorActionPreference = 'SilentlyContinue' # if a command runs into an error... Get-Process -Name zumsel # ...then $? is $false, and you can exit PowerShell # with a return value, i.e. 55 if (!$?) { exit 55 }