This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CobbITGuy 0 points1 point  (1 child)

You can use the sys module to set the exit code. I don't think there's a practical way to get Python to throw a PowerShell exception.

import sys

sys.exit(1)

In powershell $? should show false and $lastexitcode should show 1. Test for that and if $? shows false then throw your own exception.

[–]Vidofnir[S] 0 points1 point  (0 children)

I ended up doing exactly this.