Set-StrictMode should cause errors to terminate execution.
In most languages with exceptions, an unhandled exception causes the program to terminate. However, Powershell defaults to continuing on when an unhandled exception occurs.
As a result, I think it is currently widely considered a best practice to begin all scripts with:
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0
Proposed change
This should be equivalent to the above:
Set-StrictMode -Version 4.0
There is also some discussion in PowerShell/PowerShell-RFC#88 .
I think that whatever the mechanism for causing non-zero exit codes to halt execution, that should also be included in StrictMode.
Set-StrictMode should cause errors to terminate execution.
In most languages with exceptions, an unhandled exception causes the program to terminate. However, Powershell defaults to continuing on when an unhandled exception occurs.
As a result, I think it is currently widely considered a best practice to begin all scripts with:
Proposed change
This should be equivalent to the above:
There is also some discussion in PowerShell/PowerShell-RFC#88 .
I think that whatever the mechanism for causing non-zero exit codes to halt execution, that should also be included in StrictMode.