Contact Info

Crumbtrail

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

Set-StrictMode - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Set-StrictMode


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

Syntax
Set-StrictMode -Off [<CommonParameters>]

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

Description
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.