Run Script - Powershell's exit codes are not working as expected
search cancel

Run Script - Powershell's exit codes are not working as expected

book

Article ID: 169494

calendar_today

Updated On:

Products

IT Management Suite Client Management Suite

Issue/Introduction

Some syntax in PowerShell scripts do not cause the script task to exit with the proper exit code.

Example:

$Host.SetShouldExit(99)

The above causes the script to exit with error code 0 making it seem like everything in the script was successful.

Environment

ITMS 8.x

Cause

This was caused by the fix to a different issue.

Resolution

Use different syntax than what was shown above, for example:

Environment]::Exit(98)