Powershell Error Handling


JAMS monitors PowerShell script execution for more than just an exit code. We trap exceptions thrown by PowerShell and look for error objects in the PowerShell error pipeline.  This provides better error handling possibilities than a simple exit code.  Within PowerShell, your script can do:

Throw “Your error message here”

And the JAMS job will fail and show a final status of “Your error message here”.

We check the return code from the process but, a value of 0 means that our PowerShell host worked properly (even though the PowerShell script may have failed).  A return code other than 0 would indicate a problem with our host.

By setting the job's notify options, you can receive notification of non-terminating errors within Powershell scripts that might have completed with an exit code 0. 


Have more questions? Submit a request