Contact Info

Crumbtrail » Administration » Powershell » Powershell 2.0 » Set-StrictMode

Set-StrictMode - Powershell 2.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Short description
Establishes and enforces coding rules in expressions, scripts, and script blocks.

Set-StrictMode -Off [<CommonParameters>]

Set-StrictMode -Version <Version> [<CommonParameters>]

The Set-StrictMode cmdlet configures strict mode for the current scope (and all child scopes) and turns it on and o
ff. When strict mode is on, Windows PowerShell generates a terminating error when the content of an expression, scr
ipt, or script block violates basic best-practice coding rules. 

Use the Version parameter to determine which coding rules are enforced.

Unlike the Set-PSDebug cmdlet, Set-StrictMode affects only the current scope and its child scopes, so you can use i
t in a script or function without affecting the global scope.

When Set-StrictMode is off, uninitialized variables (Version 1) are assumed to have a value of 0 (zero) or $null, d
epending on type. References to non-existent properties return $null, and the results of function syntax that is no
t valid vary with the error. Unnamed variables are not permitted.