Jul5Written by:Martin 05.07.2008 07:54  I’m currently writing some PowerShell scripts to automate parts of our build process. PowerShell has a feature called “strict mode” which is similar to “option explicit” in VBScript. It’s enabled with Set-PSDebug -strict It ensures that you cannot use a variable without having assigned a value before. That’s a good idea in theory, but currently it has some drawbacks which limits its use I’m currently writing some PowerShell scripts to automate parts of our build process. PowerShell has a feature called “strict mode” which is similar to “option explicit” in VBScript. It’s enabled with Set-PSDebug -strict It ensures that you cannot use a variable without having assigned a value before. That’s a good idea in theory, but currently it has some drawbacks which limits its use When you enable strict mode in your script it’s enabled globally for the whole shell. Any script you run afterwards runs under the same mode. There are a lot of scripts which fail when running in strict mode. The most annoying for me at the moment is the excellent extended tab completion PowerTab from The PowerShell Guy. (If you want to try it, use 0.99 beta 2, which can be found here) After I run my script which enables strict mode, tab completion no longer works correctly in the shell. I know that strict mode is a debugging tool, but it’s really a pain in the *** to use right now. But there’s hope. PowerShell v2 has a better strict mode and it only influences the current scope. But v2 release is still far, far away :-( And I won’t use a technology preview for production code Tags: |