I just got a bug report about an uninitialized variable in a PowerShell script I’d written. I’d gone through and renamed most instances of a variable, but not all. If I’d put Set-PsDebug -strict
in my profile, the instance I missed would have been caught as an uninitialized variable error. I always used the analogous warning feature in other languages, such as use strict
in Perl or option explicit
in VB, but I haven’t gotten into the habit yet of using Set-PsDebug -strict
in PowerShell.
Jeffrey Snover published an article a few days ago about the new Set-StrictMode
cmdlet that will be part of version 2 of PowerShell and will replace Set-PsDebug -strict
. The new feature will be more strict and will be more finely configurable.