PowerShell: be careful when passing other bool values than $True and $False around
Posted by jpluimers on 2014/10/30
PowerShell does some powerful conversions.
Always be aware of that, especially when using booleans. For instance: strings are always TRUE, and $ inside strings are not always evaluated, and often people you define their own string to boolean conversions.
It is better to use the automatic variables $True and $False when you really want to make something is TRUE or FALSE.
Read Boolean Values and Operators – Windows PowerShell Blog – Site Home – MSDN Blogs why.
Oh and don’t forget to turn Strict-Mode on to warn for uninitialized variables and other stuff (as of PowerShell version 2; use Set-PsDebug -strict if you are still in PowerShell version 1)
–jeroen






Leave a comment