Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 4.0 » Set-StrictMode

Set-StrictMode - Powershell 4.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 »

Set-StrictMode

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

Syntax


Description
The Set-StrictMode cmdlet configures strict mode for the current scope (and all child scopes) and turns it on and off. 
When strict mode is on, Windows PowerShell generates a terminating error when the content of an expression, script, 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 it 
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, 
depending on type. References to non-existent properties return $null, and the results of function syntax that is not 
valid vary with the error. Unnamed variables are not permitted.