Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Exit Code Handling with PowerShell
The exit code of a PowerShell script is usually expected as the result of the execution of the script. However, the program powershell.exe returns the exit code of the execution of the powershell.exe itself - and this in most cases 0.
...
The example below shows how it works:
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?> <job title="How to get the exit code from a powershell script" name="PowerShellExitCode"> <script language="shell"> <![CDATA[ powershell.exe -noprofile -command "write-output test; exit 123 " echo %errorlevel% exit %errorlevel% ]]> </script> <run_time/> </job> |
...
The statement exit %errorlevel%
passes the exit code to JobScheduler. If this statement is missing then JobScheduler will not know about the exit code and will assume that it is zero (0).
See also
...