Timeline for answer to Terminating a script in PowerShell by Greg Bray
Current License: CC BY-SA 3.0
Post Revisions
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 29, 2024 at 23:48 | comment | added | ScottWelker | Throw works well for my scripts because I use trap. | |
| Jun 20, 2020 at 9:12 | history | edited | Community Bot |
Commonmark migration
|
|
| Apr 15, 2016 at 13:08 | comment | added | Djarid |
Don't forget $PSCmdlet.ThrowTerminatingError() for those instances when throw just can't get the job done (known issue with none terminating errors from throw)
|
|
| Mar 16, 2016 at 14:37 | comment | added | Josh |
For me, at least in module functions, throw exits but doesn't set an exit code. This was executed via CLI e.g. powershell -command "& module-function ...". I needed to convert those functions to throw to a wrapping try-catch and exit from that wrapping catch in order to actually output an error exit code.
|
|
| Feb 10, 2014 at 15:59 | comment | added | Paul Turner | This seems the most-correct way to terminate an activity with an error. It delegates to the caller to attempt to handle the error, which is much better than simply attempting to terminate abruptly. | |
| Dec 12, 2013 at 23:44 | history | answered | Greg Bray | CC BY-SA 3.0 |