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.