Adding a custom exit code to a PowerShell Job

Follow

In some cases, users may wish to force a PowerShell Job to exit at a specific point and add a custom exit code.  In order to do this you can use the following variable in your PowerShell Source:

$Host.SetShouldExit(411)

In this example, 411 is the custom exit code that is being specified and can be set to a users specific needs.

This custom exit code can then be added to the Source Options tab in the Job properties. In our example above, the exit code of 411 signifies an Informational exit code value for the Job.

Have more questions? Submit a request

Comments