Monday, March 27, 2023
HomePowershellEnabling Strict Mode – SID-500.COM

Enabling Strict Mode – SID-500.COM


PowerShell could be very forgiving of errors. For instance, if you happen to name one thing that doesn’t exist, then no error message is displayed. On this quick article I wish to present you easy methods to make PowerShell a bit extra strict with the strict mode.

Think about you’re calling a variable that doesn’t exist. PowerShell will show no errors.

One other instance. Why is it displaying true? $a doesn’t exist.

With strictmode mode, nonetheless, PowerShell will return an error. First we have to allow it.

Set-StrictMode -Model Newest

Now PowerShell will show an error: “The variable ‘$a’ can’t be retrieved as a result of it has not been set.

That was what I wished to point out. Have enjoyable with PowerShell.

Revealed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Marketing consultant, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments