With the Set-StrictMode cmdlet you can turn PowerShell’s Strict Mode on, which ensures that you follow best practices in your script. I’ll show you the differences between Strict Mode versions 1.0 and 2.0.
Why you should care
By default, PowerShell is pretty lenient with certain programming rules that are considered bad practice. This can be both a blessing and a curse: a blessing in that it allows some flexibility when developing a script or learning PowerShell for the first time, but a curse in that certain classes of bugs and poor design choices can creep into your code and make troubleshooting a nightmare. Leaning how and why to use Strict Mode will help you level-up your PowerShell development skills and stamp out those pesky bugs.