mikaelsnavy
11/29/2017 - 6:49 PM

PowerShell 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 }