DROTHISM

Creating PowerShell Exit Codes

Posted by Drothism on Sep 10th, 2008

I needed to create a PowerShell script today that would return exit codes. Simply look it up on the internet you say. Well after 30 minutes of searching I did find the trick and thought embedding on here would ensure I could find it next time it was needed…

$host.SetShouldExit($exitcode)

$host is a PowerShell reserved variable so you don’t need to define it, and $exitcode is the INT you want your script to return when it exits.

Leave a reply

You must be logged in to post a comment.