diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AlignAssignmentStatement.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AlignAssignmentStatement.md index c12847e..3ddf379 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AlignAssignmentStatement.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AlignAssignmentStatement.md @@ -1,6 +1,6 @@ --- description: Align assignment statement -ms.date: 06/12/2026 +ms.date: 07/21/2026 ms.topic: reference title: AlignAssignmentStatement --- @@ -8,6 +8,8 @@ title: AlignAssignmentStatement **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects misaligned assignment operators in hashtables and enum definitions. Consecutive @@ -51,7 +53,7 @@ enum Enum { } ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidAssignmentToAutomaticVariable.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidAssignmentToAutomaticVariable.md index a7dc262..a3cff6f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidAssignmentToAutomaticVariable.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidAssignmentToAutomaticVariable.md @@ -1,6 +1,6 @@ --- description: Changing automatic variables might have undesired side effects -ms.date: 06/12/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidAssignmentToAutomaticVariable --- @@ -8,27 +8,21 @@ title: AvoidAssignmentToAutomaticVariable **Severity Level: Warning** +**Default state: Always enabled** + ## Description -This rule detects assignments to automatic variables and parameter names that use automatic variable -names. PowerShell automatically defines variables that store internal state information and manages -them on its own. Even though you _can_ override many automatic variables, doing so can have -unexpected effects for users and make your code harder to maintain and debug. +Avoid using automatic variable names in your functions and parameters. This rule detects assignments +to automatic variables and parameter names that use automatic variable names. PowerShell +automatically defines variables that store internal state information and manages them on its own. +Even though you _can_ override many automatic variables, doing so can have unexpected effects for +users and make your code harder to maintain and debug. -Avoid using automatic variable names in your functions and parameters. Reserve automatic variables -for PowerShell's internal use only, and rely on them only to read state information. +Reserve automatic variables for PowerShell's internal use only, and rely on them only to read state +information. To learn more, see [about_Automatic_Variables][01]. - - -## How - -Use variable names in functions or their parameters that do not conflict with automatic variables. - ## Example ### Noncompliant @@ -50,6 +44,16 @@ function Get-CustomErrorMessage($ErrorMessage){ $Error = "Error occurred: $Error function Get-CustomErrorMessage($ErrorMessage){ $FinalErrorMessage = "Error occurred: $ErrorMessage" } ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_automatic_variables +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueForMandatoryParameter.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueForMandatoryParameter.md index a43791f..adbbae4 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueForMandatoryParameter.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueForMandatoryParameter.md @@ -1,6 +1,6 @@ --- description: Avoid Default Value For Mandatory Parameter -ms.date: 06/12/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidDefaultValueForMandatoryParameter --- @@ -8,6 +8,8 @@ title: AvoidDefaultValueForMandatoryParameter **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when mandatory parameters have default values assigned. Mandatory parameters @@ -45,3 +47,16 @@ function Test ) } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueSwitchParameter.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueSwitchParameter.md index c34701d..e964cdb 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueSwitchParameter.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidDefaultValueSwitchParameter.md @@ -1,6 +1,6 @@ --- description: Switch parameters should not default to $true -ms.date: 06/12/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidDefaultValueSwitchParameter --- @@ -8,6 +8,8 @@ title: AvoidDefaultValueSwitchParameter **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects switch parameters that are assigned a default value of `$true`. Switch parameters @@ -64,6 +66,17 @@ function Test-Script } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/scripting/developer/cmdlet/strongly-encouraged-development-guidelines#parameters-that-take-true-and-false +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidExclaimOperator.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidExclaimOperator.md index a6385dc..75e5bf2 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidExclaimOperator.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidExclaimOperator.md @@ -1,6 +1,6 @@ --- description: Avoid exclaim operator -ms.date: 05/28/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidExclaimOperator --- @@ -8,6 +8,8 @@ title: AvoidExclaimOperator **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects the use of the negation operator (an exclamation mark, `!`) and recommends using @@ -16,9 +18,6 @@ the `-not` operator instead for improved readability and consistency with PowerS The `-not` operator is more explicit and aligns with PowerShell's verbose style, making code easier to understand at a glance. -This rule is **disabled** by default. Enable it explicitly during ScriptAnalyzer invocation if -desired. - ## Example ### Noncompliant @@ -33,12 +32,7 @@ $MyVar = !$true $MyVar = -not $true ``` -## Parameters - -### Enable - -This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a -boolean value. To enable this rule, set this parameter to `$true`. The default value is `$false`. +## Configure rule ```powershell Rules = @{ @@ -47,3 +41,10 @@ Rules = @{ } } ``` + +## Parameters + +### Enable + +This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a +boolean value. To enable this rule, set this parameter to `$true`. The default value is `$false`. diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalAliases.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalAliases.md index b72fc62..ffb03d6 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalAliases.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalAliases.md @@ -1,6 +1,6 @@ --- description: Avoid global aliases. -ms.date: 05/28/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidGlobalAliases --- @@ -8,6 +8,8 @@ title: AvoidGlobalAliases **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the use of the `New-Alias` command to create aliases in the global scope. Global @@ -32,6 +34,16 @@ New-Alias -Name Name -Value Value -Scope Global New-Alias -Name Name1 -Value Value ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + [01]: /powershell/module/microsoft.powershell.core/about/about_scopes +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalFunctions.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalFunctions.md index 80dd839..83b9aec 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalFunctions.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalFunctions.md @@ -1,6 +1,6 @@ --- description: Avoid global functions and aliases -ms.date: 06/28/2023 +ms.date: 07/21/2026 ms.topic: reference title: AvoidGlobalFunctions --- @@ -8,6 +8,8 @@ title: AvoidGlobalFunctions **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects function definitions that use the `global:` scope modifier on the function name to @@ -32,5 +34,16 @@ function global:functionName {} function functionName {} ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_scopes +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md index df473c2..0fa4851 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md @@ -1,6 +1,6 @@ --- description: Avoid global variables. -ms.date: 06/23/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidGlobalVars --- @@ -8,6 +8,8 @@ title: AvoidGlobalVars **Severity Level: Warning** +**Default state: Always enabled** + ## Description You should avoid modifying global variables in your scripts and functions because other scripts or @@ -56,7 +58,18 @@ Test-NotGlobal 'bar' $var1 ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][04]. + [01]: /powershell/module/microsoft.powershell.core/about/about_automatic_variables [02]: /powershell/module/microsoft.powershell.core/about/about_preference_variables [03]: /powershell/module/microsoft.powershell.core/about/about_scopes +[04]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidInvokingEmptyMembers.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidInvokingEmptyMembers.md index 35631e9..d4f37ad 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidInvokingEmptyMembers.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidInvokingEmptyMembers.md @@ -1,6 +1,6 @@ --- description: Avoid invoking empty members. -ms.date: 05/28/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidInvokingEmptyMembers --- @@ -8,6 +8,8 @@ title: AvoidInvokingEmptyMembers **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects expressions where the code uses the [member-access operator][01] (`.`) where the @@ -33,5 +35,16 @@ $MyString = 'abc' $MyString.('length') ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_operators#member-access-operator- +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md index d1c33b0..add4f28 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidLongLines.md @@ -1,6 +1,6 @@ --- description: Avoid long lines -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidLongLines --- @@ -8,11 +8,12 @@ title: AvoidLongLines **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects lines that exceed the configured maximum length, including leading spaces -(indentation). The default maximum line length is 120 characters. This rule is **disabled** by -default and must be explicitly enabled through rule configuration settings. +(indentation). The default maximum line length is 120 characters. ## Example diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidMultipleTypeAttributes.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidMultipleTypeAttributes.md index d4fd2fd..6e320eb 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidMultipleTypeAttributes.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidMultipleTypeAttributes.md @@ -1,6 +1,6 @@ --- description: Avoid multiple type specifiers on parameters -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidMultipleTypeAttributes --- @@ -8,6 +8,8 @@ title: AvoidMultipleTypeAttributes **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects parameters that have multiple type specifiers applied to them. Parameters @@ -47,3 +49,16 @@ function Test-Script ) } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md index 0706e29..7df620d 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidNullOrEmptyHelpMessageAttribute.md @@ -1,6 +1,6 @@ --- description: Avoid using null or empty HelpMessage parameter attribute -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidNullOrEmptyHelpMessageAttribute --- @@ -8,6 +8,8 @@ title: AvoidNullOrEmptyHelpMessageAttribute **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects [HelpMessage][01] attributes that contain null values, empty strings, or no value @@ -71,5 +73,16 @@ Function GoodFuncHelpMessage } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters#helpmessage-argument +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md index 8bd9c0f..523773a 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidOverwritingBuiltInCmdlets.md @@ -1,6 +1,6 @@ --- description: Avoid overwriting built-in cmdlets -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidOverwritingBuiltInCmdlets --- @@ -8,6 +8,8 @@ title: AvoidOverwritingBuiltInCmdlets **Severity Level: Warning** +**Default state: Enabled** + ## Description This rule detects and warns when a script defines a function that uses the name of a built-in cmdlet @@ -52,9 +54,10 @@ following lines in your settings file. ```powershell @{ - 'Rules' = @{ - 'PSAvoidOverwritingBuiltInCmdlets' = @{ - 'PowerShellVersion' = @('core-7.0.0-windows') + Rules = @{ + PSAvoidOverwritingBuiltInCmdlets = @{ + Enable = $true + PowerShellVersion = @('core-7.0.0-windows') } } } diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidReservedWordsAsFunctionNames.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidReservedWordsAsFunctionNames.md index 7fd2117..7f337c9 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidReservedWordsAsFunctionNames.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidReservedWordsAsFunctionNames.md @@ -1,6 +1,6 @@ --- description: Avoid reserved words as function names -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidReservedWordsAsFunctionNames --- @@ -8,6 +8,8 @@ title: AvoidReservedWordsAsFunctionNames **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects function names that use PowerShell reserved words. Using reserved words as @@ -36,5 +38,16 @@ function myFunction { } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_reserved_words +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md index e9d757f..7338e76 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidSemicolonsAsLineTerminators.md @@ -1,6 +1,6 @@ --- description: Avoid semicolons as line terminators -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidSemicolonsAsLineTerminators --- @@ -8,6 +8,8 @@ title: AvoidSemicolonsAsLineTerminators **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects semicolons used as line terminators at the end of statements. In PowerShell, @@ -15,8 +17,7 @@ line-ending semicolons are redundant and detract from code readability. Although statement separators on a single line, using them as line terminators is discouraged. Avoid using semicolons at the end of lines. -This rule promotes cleaner, more maintainable code by removing unnecessary semicolons. This rule -isn't enabled by default. +This rule promotes cleaner, more maintainable code by removing unnecessary semicolons. ## Example @@ -42,7 +43,7 @@ Install-Module -Name PSScriptAnalyzer $a = 1 + $b ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md index f6fc10d..b861e03 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidShouldContinueWithoutForce.md @@ -1,6 +1,6 @@ --- description: Avoid using ShouldContinue without boolean Force parameter -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidShouldContinueWithoutForce --- @@ -8,6 +8,8 @@ title: AvoidShouldContinueWithoutForce **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects functions that use `ShouldContinue` without a **Force** parameter. Functions that @@ -59,6 +61,17 @@ Function Test-ShouldContinue } ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][03]. + + [01]: /powershell/module/microsoft.powershell.core/about/about_functions_cmdletbindingattribute [02]: /powershell/module/microsoft.powershell.core/about/about_functions_advanced_methods +[03]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidTrailingWhitespace.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidTrailingWhitespace.md index 02c02d2..f3bc8b0 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidTrailingWhitespace.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidTrailingWhitespace.md @@ -1,6 +1,6 @@ --- description: Avoid trailing whitespace -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidTrailingWhitespace --- @@ -8,6 +8,8 @@ title: AvoidTrailingWhitespace **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects lines that end with trailing whitespace characters. Lines shouldn't end with @@ -51,5 +53,16 @@ Get-Process ` | Where-Object { $_.CPU -gt 100 } ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + [01]: /powershell/module/microsoft.powershell.core/about/about_parsing +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingAllowUnencryptedAuthentication.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingAllowUnencryptedAuthentication.md index 2e76b19..2fe1af7 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingAllowUnencryptedAuthentication.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingAllowUnencryptedAuthentication.md @@ -1,6 +1,6 @@ --- description: Avoid sending credentials and secrets over unencrypted connections -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingAllowUnencryptedAuthentication --- @@ -8,6 +8,8 @@ title: AvoidUsingAllowUnencryptedAuthentication **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the **AllowUnencryptedAuthentication** parameter used with `Invoke-WebRequest` and @@ -33,6 +35,17 @@ Invoke-WebRequest foo -AllowUnencryptedAuthentication Invoke-WebRequest foo ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][03]. + + [01]: /powershell/module/microsoft.powershell.utility/invoke-webrequest [02]: /powershell/module/microsoft.powershell.utility/invoke-restmethod +[03]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingBrokenHashAlgorithms.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingBrokenHashAlgorithms.md index 8371c93..0306aca 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingBrokenHashAlgorithms.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingBrokenHashAlgorithms.md @@ -1,6 +1,6 @@ --- description: Avoid using broken hash algorithms -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingBrokenHashAlgorithms --- @@ -8,6 +8,8 @@ title: AvoidUsingBrokenHashAlgorithms **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the use of cryptographically broken hash algorithms `MD5` and `SHA-1`. Avoid using @@ -30,3 +32,16 @@ Get-FileHash foo.txt -Algorithm MD5 ```powershell Get-FileHash foo.txt -Algorithm SHA256 ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingCmdletAliases.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingCmdletAliases.md index b92aa87..2204a21 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingCmdletAliases.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingCmdletAliases.md @@ -1,6 +1,6 @@ --- description: Avoid using cmdlet aliases or omitting the Get- prefix -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingCmdletAliases --- @@ -8,6 +8,8 @@ title: AvoidUsingCmdletAliases **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the use of cmdlet aliases and omission of the `Get-` prefix in implicit alias @@ -55,4 +57,15 @@ file content to the following. } } } -``` \ No newline at end of file +``` + +While this rule is configurable, it's always enabled. Use one of the following methods to avoid +using this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingComputerNameHardcoded.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingComputerNameHardcoded.md index 73ac31f..a580300 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingComputerNameHardcoded.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingComputerNameHardcoded.md @@ -1,6 +1,6 @@ --- description: Avoid using hardcoded computer names -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingComputerNameHardcoded --- @@ -8,6 +8,8 @@ title: AvoidUsingComputerNameHardcoded **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects hard-coded computer names in the `ComputerName` parameter of cmdlets. Hard-coded @@ -37,3 +39,16 @@ Function Invoke-MyCommand ($ComputerName) Invoke-Command -Port 343 -ComputerName $ComputerName } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md index 30a35f2..ac7ffb5 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingConvertToSecureStringWithPlainText.md @@ -1,6 +1,6 @@ --- description: Avoid Using SecureString With Plain Text -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingConvertToSecureStringWithPlainText --- @@ -8,6 +8,8 @@ title: AvoidUsingConvertToSecureStringWithPlainText **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects the use of the `AsPlainText` parameter with the `ConvertTo-SecureString` command, @@ -38,6 +40,17 @@ $EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force $SecureUserInput = Read-Host 'Please enter your secure code' -AsSecureString ``` - +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][03]. + + [01]: /dotnet/api/system.security.securestring [02]: https://www.powershellgallery.com/packages/Microsoft.PowerShell.SecretStore +[03]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDeprecatedManifestFields.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDeprecatedManifestFields.md index fd83bea..dc7d9b9 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDeprecatedManifestFields.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDeprecatedManifestFields.md @@ -1,6 +1,6 @@ --- description: Avoid using deprecated manifest fields -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingDeprecatedManifestFields --- @@ -8,6 +8,8 @@ title: AvoidUsingDeprecatedManifestFields **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the usage of deprecated manifest fields in module manifest files (`.psd1`) that @@ -35,3 +37,16 @@ RootModule ='psscriptanalyzer' ModuleVersion = '1.0' ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDoubleQuotesForConstantString.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDoubleQuotesForConstantString.md index bc51d46..6400191 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDoubleQuotesForConstantString.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingDoubleQuotesForConstantString.md @@ -1,6 +1,6 @@ --- description: Avoid using double quotes if the string is constant -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingDoubleQuotesForConstantString --- @@ -8,6 +8,8 @@ title: AvoidUsingDoubleQuotesForConstantString **Severity Level: Information** +**Default state: Disabled** + ## Description This rule detects static strings enclosed with double quotes (`""`) with text that doesn't @@ -37,3 +39,20 @@ $constantValue = "I Love PowerShell" ```powershell $constantValue = 'I Love PowerShell' ``` + +## Configure rule + +```powershell +Rules = @{ + PSAvoidUsingDoubleQuotesForConstantString = @{ + Enable = $true + } +} +``` + +## Parameters + +### Enable + +This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a +boolean value. To enable this rule, set this parameter to `$true`. The default value is `$false`. diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingEmptyCatchBlock.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingEmptyCatchBlock.md index 329d94e..443370a 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingEmptyCatchBlock.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingEmptyCatchBlock.md @@ -1,6 +1,6 @@ --- description: Avoid using empty catch block -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingEmptyCatchBlock --- @@ -8,6 +8,8 @@ title: AvoidUsingEmptyCatchBlock **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects empty `catch` blocks. Empty catch blocks are problematic because they silently @@ -50,3 +52,16 @@ catch [DivideByZeroException] throw 'DivideByZeroException' } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingInvokeExpression.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingInvokeExpression.md index 19e1c37..408ad65 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingInvokeExpression.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingInvokeExpression.md @@ -1,6 +1,6 @@ --- description: Avoid using Invoke-Expression -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingInvokeExpression --- @@ -8,6 +8,8 @@ title: AvoidUsingInvokeExpression **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the use of the `Invoke-Expression` command, which poses security risks in your @@ -31,3 +33,16 @@ Invoke-Expression 'Get-Process' ```powershell Get-Process ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPlainTextForPassword.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPlainTextForPassword.md index 0334ec7..d46a30e 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPlainTextForPassword.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPlainTextForPassword.md @@ -1,11 +1,13 @@ --- description: Avoid using plain text for Password parameter -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingPlainTextForPassword --- # AvoidUsingPlainTextForPassword +**Default state: Always enabled** + **Severity Level: Warning** ## Description @@ -59,5 +61,16 @@ function Test-Script } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /dotnet/api/system.security.securestring +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPositionalParameters.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPositionalParameters.md index 4bd6a78..8c3f4ca 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPositionalParameters.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingPositionalParameters.md @@ -1,6 +1,6 @@ --- description: Avoid using positional parameters -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingPositionalParameters --- @@ -8,6 +8,8 @@ title: AvoidUsingPositionalParameters **Severity Level: Information** +**Default state: Enabled** + ## Description This rule detects when commands are called with three or more positional parameters instead of using diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingUsernameAndPasswordParams.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingUsernameAndPasswordParams.md index 1d7c030..d9036c5 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingUsernameAndPasswordParams.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingUsernameAndPasswordParams.md @@ -1,6 +1,6 @@ --- description: Avoid using username and password parameters -ms.date: 06/01/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingUsernameAndPasswordParams --- @@ -8,6 +8,8 @@ title: AvoidUsingUsernameAndPasswordParams **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects functions that use separate username and password parameters instead of a single @@ -47,3 +49,15 @@ function Test-Script ... } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWMICmdlet.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWMICmdlet.md index d26b4aa..177b287 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWMICmdlet.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWMICmdlet.md @@ -1,6 +1,6 @@ --- description: Avoid using WMI cmdlets -ms.date: 06/02/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingWMICmdlet --- @@ -8,6 +8,8 @@ title: AvoidUsingWMICmdlet **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects the use of Windows Management Instrumentation (WMI) cmdlets. Since PowerShell 3.0, @@ -46,3 +48,15 @@ Invoke-WmiMethod -Class Win32_Process -Name 'Create' -ArgumentList @{ CommandLin Get-CimInstance -Query 'Select * from Win32_Process where name LIKE "myprocess%"' | Remove-CimInstance Invoke-CimMethod -ClassName Win32_Process -MethodName 'Create' -Arguments @{ CommandLine = 'notepad.exe' } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWriteHost.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWriteHost.md index 2160623..46f4d74 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWriteHost.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidUsingWriteHost.md @@ -1,6 +1,6 @@ --- description: Avoid using Write-Host cmdlet -ms.date: 06/02/2026 +ms.date: 07/21/2026 ms.topic: reference title: AvoidUsingWriteHost --- @@ -8,6 +8,8 @@ title: AvoidUsingWriteHost **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects usage of `Write-Host` in functions that don't use the `Show` verb. `Write-Host` is @@ -54,7 +56,18 @@ function Show-Something { } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][04]. + [01]: /powershell/module/microsoft.powershell.utility/write-host [02]: /powershell/module/microsoft.powershell.utility/write-output [03]: /powershell/module/microsoft.powershell.utility/write-verbose +[04]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscExamplesPresent.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscExamplesPresent.md index cd15788..258fa4b 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscExamplesPresent.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscExamplesPresent.md @@ -1,6 +1,6 @@ --- description: DSC examples are present -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCDscExamplesPresent --- @@ -8,6 +8,8 @@ title: DSCDscExamplesPresent **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects if Desired State Configuration (DSC) examples for a given resource are present. @@ -59,3 +61,16 @@ In this case, to fix this warning, add examples in the following way: - Examples - MyDscResource_Example1.ps1 - MyDscResource_Example2.ps1 + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscTestsPresent.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscTestsPresent.md index 663a6aa..500f09f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscTestsPresent.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCDscTestsPresent.md @@ -1,6 +1,6 @@ --- description: DSC tests are present -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCDscTestsPresent --- @@ -8,6 +8,8 @@ title: DSCDscTestsPresent **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects if Desired State Configuration (DSC) tests for a given resource are present. @@ -58,3 +60,16 @@ In this case, to fix this warning, add tests in the following way: - MyDscResource.psd1 - Tests - MyDscResource_Tests.ps1 + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCReturnCorrectTypesForDSCFunctions.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCReturnCorrectTypesForDSCFunctions.md index 99dc1a4..c107c5b 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCReturnCorrectTypesForDSCFunctions.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCReturnCorrectTypesForDSCFunctions.md @@ -1,6 +1,6 @@ --- description: Return correct types for DSC functions -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCReturnCorrectTypesForDSCFunctions --- @@ -8,6 +8,8 @@ title: DSCReturnCorrectTypesForDSCFunctions **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects if functions in Desired State Configuration (DSC) resources have specific return @@ -149,3 +151,16 @@ class MyDSCResource } } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCStandardDSCFunctionsInResource.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCStandardDSCFunctionsInResource.md index 96a8125..61ab3d5 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCStandardDSCFunctionsInResource.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCStandardDSCFunctionsInResource.md @@ -1,6 +1,6 @@ --- description: Use standard DSC Get, Set, and Test TargetResource functions in a resource -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCStandardDSCFunctionsInResource --- @@ -8,6 +8,8 @@ title: DSCStandardDSCFunctionsInResource **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects if all Desired State Configuration (DSC) resources implement the correct @@ -140,3 +142,16 @@ class MyDSCResource } } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalMandatoryParametersForDSC.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalMandatoryParametersForDSC.md index 00d45f2..0dedb33 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalMandatoryParametersForDSC.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalMandatoryParametersForDSC.md @@ -1,6 +1,6 @@ --- description: Use identical mandatory parameters for DSC Get, Set, and Test TargetResource functions in a resource -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCUseIdenticalMandatoryParametersForDSC --- @@ -8,6 +8,8 @@ title: DSCUseIdenticalMandatoryParametersForDSC **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects if MOF-based Desired State Configuration (DSC) resources have properties @@ -137,3 +139,16 @@ function Test-TargetResource ) } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalParametersForDSC.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalParametersForDSC.md index 98e3e33..d9c6e32 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalParametersForDSC.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseIdenticalParametersForDSC.md @@ -1,6 +1,6 @@ --- description: Use identical parameters for DSC Get, Set, and Test TargetResource functions in a resource -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCUseIdenticalParametersForDSC --- @@ -8,6 +8,8 @@ title: DSCUseIdenticalParametersForDSC **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects if the `Get-TargetResource`, `Set-TargetResource`, and `Test-TargetResource` @@ -106,3 +108,16 @@ function Test-TargetResource ... } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseVerboseMessageInDSCResource.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseVerboseMessageInDSCResource.md index 3154111..a9755fb 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseVerboseMessageInDSCResource.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/DSCUseVerboseMessageInDSCResource.md @@ -1,6 +1,6 @@ --- description: Use verbose message in DSC resources -ms.date: 06/03/2026 +ms.date: 07/21/2026 ms.topic: reference title: DSCUseVerboseMessageInDSCResource --- @@ -8,6 +8,8 @@ title: DSCUseVerboseMessageInDSCResource **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects DSC resources that don't include `Write-Verbose` messages in their functions or @@ -40,5 +42,16 @@ Function Test-Function } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.utility/write-verbose +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/MisleadingBacktick.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/MisleadingBacktick.md index 3ea4ebc..e4ab315 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/MisleadingBacktick.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/MisleadingBacktick.md @@ -1,6 +1,6 @@ --- description: Misleading backtick -ms.date: 06/04/2026 +ms.date: 07/21/2026 ms.topic: reference title: MisleadingBacktick --- @@ -8,6 +8,8 @@ title: MisleadingBacktick **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects lines where a trailing backtick is followed by one or more whitespace characters. @@ -28,6 +30,19 @@ Get-Process ` ### Compliant ```powershell -Get-Process ` -| Where-Object CPU -gt 100 +Get-Process | + Where-Object CPU -gt 100 ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/MissingModuleManifestField.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/MissingModuleManifestField.md index 835ff62..62c4df1 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/MissingModuleManifestField.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/MissingModuleManifestField.md @@ -1,6 +1,6 @@ --- description: Module manifest fields -ms.date: 06/04/2026 +ms.date: 07/21/2026 ms.topic: reference title: MissingModuleManifestField --- @@ -8,6 +8,8 @@ title: MissingModuleManifestField **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when a module manifest is missing a required field. A module manifest is a `.psd1` @@ -48,5 +50,16 @@ All other keys are optional and the order you place them doesn't matter. To lear } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_module_manifests +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceCloseBrace.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceCloseBrace.md index aa249b0..8266944 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceCloseBrace.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceCloseBrace.md @@ -1,6 +1,6 @@ --- description: Place close braces consistently -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: PlaceCloseBrace --- @@ -8,11 +8,13 @@ title: PlaceCloseBrace **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects closing braces (`}`) that aren't placed on a new line by themselves or that are followed by empty lines. Close brace placement should follow a consistent style. It should be on a -new line by itself and shouldn't be followed by an empty line. This rule is **disabled** by default. +new line by itself and shouldn't be followed by an empty line. ## Example @@ -33,7 +35,7 @@ if ($true) { Get-Process ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceOpenBrace.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceOpenBrace.md index 9b74c57..8096b48 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceOpenBrace.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PlaceOpenBrace.md @@ -1,6 +1,6 @@ --- description: Place open braces consistently -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: PlaceOpenBrace --- @@ -8,11 +8,13 @@ title: PlaceOpenBrace **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects opening braces (`{`) that don't follow a consistent style. Opening braces can be required on the same line as the preceding keyword or on the next line, based on configuration. You -can also require a new line after the opening brace. This rule is **disabled** by default. +can also require a new line after the opening brace. ## Example @@ -33,7 +35,7 @@ if ($true) { } ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectComparisonWithNull.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectComparisonWithNull.md index 8b0f375..daf66fa 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectComparisonWithNull.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectComparisonWithNull.md @@ -1,6 +1,6 @@ --- description: Comparison with null -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: PossibleIncorrectComparisonWithNull --- @@ -8,6 +8,8 @@ title: PossibleIncorrectComparisonWithNull **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects comparisons where `$null` isn't on the left side of the comparison operator. To @@ -77,3 +79,16 @@ function Test-CompareWithNull } } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfAssignmentOperator.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfAssignmentOperator.md index eb8761f..d896e3c 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfAssignmentOperator.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfAssignmentOperator.md @@ -1,6 +1,6 @@ --- description: Use the PowerShell equality operator (-eq) instead of assignment (=) in conditional statements -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: PossibleIncorrectUsageOfAssignmentOperator --- @@ -8,6 +8,8 @@ title: PossibleIncorrectUsageOfAssignmentOperator **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects when conditional statements use `=` or `==` instead of the PowerShell equality @@ -72,6 +74,17 @@ if ($a = Get-Something) # Only execute action if command returns something and a } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][03]. + [01]: /powershell/module/microsoft.powershell.core/about/about_assignment_operators -[02]: /powershell/module/microsoft.powershell.core/about/about_comparison_operators#-eq-and--ne \ No newline at end of file +[02]: /powershell/module/microsoft.powershell.core/about/about_comparison_operators#-eq-and--ne +[03]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfRedirectionOperator.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfRedirectionOperator.md index 7ceb152..8c2625c 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfRedirectionOperator.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/PossibleIncorrectUsageOfRedirectionOperator.md @@ -1,6 +1,6 @@ --- description: Use -gt or -ge comparison operators instead of redirection operators -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: PossibleIncorrectUsageOfRedirectionOperator --- @@ -8,6 +8,8 @@ title: PossibleIncorrectUsageOfRedirectionOperator **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects the use of the sequences `>` and `>=` in conditional statements where comparison @@ -37,3 +39,16 @@ if ($a -gt $b) ... } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ProvideCommentHelp.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ProvideCommentHelp.md index 2f7567b..252190f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ProvideCommentHelp.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ProvideCommentHelp.md @@ -1,12 +1,14 @@ --- description: Basic comment help -ms.date: 06/05/2026 +ms.date: 07/21/2026 ms.topic: reference title: ProvideCommentHelp --- # ProvideCommentHelp -**Severity Level: Info** +**Severity Level: Information** + +**Default state: Enabled** ## Description @@ -74,7 +76,7 @@ function Get-File } ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md index b06c760..55072c3 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/README.md @@ -1,6 +1,6 @@ --- description: List of PSScriptAnalyzer rules -ms.date: 06/25/2026 +ms.date: 07/21/2026 ms.topic: reference title: List of PSScriptAnalyzer rules --- @@ -46,7 +46,7 @@ title: List of PSScriptAnalyzer rules | [AvoidUsingEmptyCatchBlock][26] | Warning | Always enabled | | | [AvoidUsingInvokeExpression][27] | Warning | Always enabled | | | [AvoidUsingPlainTextForPassword][28] | Warning | Always enabled | | -| [AvoidUsingPositionalParameters][29] | Warning | Always enabled | | +| [AvoidUsingPositionalParameters][29] | Information | Enabled | Yes | | [AvoidUsingUsernameAndPasswordParams][30] | Error | Always enabled | | | [AvoidUsingWMICmdlet][31] | Warning | Always enabled | | | [AvoidUsingWriteHost][32] | Warning | Always enabled | | diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedCmdletChar.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedCmdletChar.md index 9e781eb..8afcd56 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedCmdletChar.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedCmdletChar.md @@ -1,6 +1,6 @@ --- description: Reserved cmdlet characters -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: ReservedCmdletChar --- @@ -8,6 +8,8 @@ title: ReservedCmdletChar **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects when reserved characters are used in function or cmdlet names. You can't use @@ -54,3 +56,16 @@ function MyFunction[1] function MyFunction {...} ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedParams.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedParams.md index a892e6b..6d0acf9 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedParams.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReservedParams.md @@ -1,6 +1,6 @@ --- description: Reserved parameters -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: ReservedParams --- @@ -8,6 +8,8 @@ title: ReservedParams **Severity Level: Error** +**Default state: Always enabled** + ## Description This rule detects when you attempt to redefine [common parameters][01] in an advanced function. When @@ -46,4 +48,16 @@ function Test } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + [01]: /powershell/module/microsoft.powershell.core/about/about_commonparameters +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md index bbe5adb..d3bcdb0 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md @@ -1,6 +1,6 @@ --- description: ReviewUnusedParameter -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: ReviewUnusedParameter --- @@ -8,6 +8,8 @@ title: ReviewUnusedParameter **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects parameters that are declared but not used in a script, scriptblock, or function @@ -65,3 +67,14 @@ you to add extra commands that accept scriptblocks that this rule should examine } } ``` + +While this rule is configurable, it's always enabled. Use one of the following methods to avoid +using this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ShouldProcess.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ShouldProcess.md index 3778828..9a19a4f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/ShouldProcess.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/ShouldProcess.md @@ -1,6 +1,6 @@ --- description: Pair ShouldProcess with SupportsShouldProcess -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: ShouldProcess --- @@ -8,6 +8,8 @@ title: ShouldProcess **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects mismatches between `SupportsShouldProcess` declarations and `ShouldProcess` calls. @@ -74,7 +76,18 @@ function Set-File } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][04]. + [01]: /powershell/module/microsoft.powershell.core/about/about_functions_advanced_methods [02]: /powershell/module/microsoft.powershell.core/about/about_Functions_CmdletBindingAttribute [03]: /powershell/scripting/learn/deep-dives/everything-about-shouldprocess +[04]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md index 6991973..4e90666 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md @@ -1,6 +1,6 @@ --- description: Approved cmdlet verbs -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseApprovedVerbs --- @@ -8,6 +8,8 @@ title: UseApprovedVerbs **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects cmdlets that use unapproved verbs in their names. All cmdlets must use approved @@ -38,5 +40,16 @@ function Update-Item { } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseBOMForUnicodeEncodedFile.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseBOMForUnicodeEncodedFile.md index 01e6c15..5ebf56b 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseBOMForUnicodeEncodedFile.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseBOMForUnicodeEncodedFile.md @@ -1,6 +1,6 @@ --- description: Use BOM encoding for non-ASCII files -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseBOMForUnicodeEncodedFile --- @@ -8,6 +8,8 @@ title: UseBOMForUnicodeEncodedFile **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects files that are encoded with Unicode or other non-ASCII formats but don't include a @@ -49,8 +51,24 @@ Set-Content -Path .\script.ps1 -Value "Write-Output 'café'" -Encoding utf8NoBOM Set-Content -Path .\script.ps1 -Value "Write-Output 'café'" -Encoding utf8BOM ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][01]. + ## See also -- [about_Character_Encoding](/powershell/module/microsoft.powershell.core/about/about_character_encoding) -- [Set-Content](/powershell/module/microsoft.powershell.management/set-content) -- [Understanding file encoding in Visual Studio Code and PowerShell](/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding) +- [about_Character_Encoding][02] +- [Set-Content][03] +- [Understanding file encoding in Visual Studio Code and PowerShell][04] + + +[01]: ../using-scriptanalyzer.md +[02]: /powershell/module/microsoft.powershell.core/about/about_character_encoding +[03]: /powershell/module/microsoft.powershell.management/set-content +[04]: /powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCmdletCorrectly.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCmdletCorrectly.md index ddc24f5..ac4d8e1 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCmdletCorrectly.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCmdletCorrectly.md @@ -1,6 +1,6 @@ --- description: Use cmdlets correctly -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCmdletCorrectly --- @@ -8,6 +8,8 @@ title: UseCmdletCorrectly **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects commands that are invoked without their required mandatory parameters. When you @@ -36,3 +38,17 @@ Function Set-TodaysDate () ... } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[01]: /powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCmdlets.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCmdlets.md index afe3c72..a416138 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCmdlets.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCmdlets.md @@ -1,6 +1,6 @@ --- description: Use compatible cmdlets -ms.date: 06/08/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCompatibleCmdlets --- @@ -8,6 +8,8 @@ title: UseCompatibleCmdlets **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects cmdlets that aren't available for the PowerShell edition, version, and operating @@ -25,7 +27,7 @@ Where: - `` is the PowerShell version - `` is `Windows`, `Linux`, `Linux-Arm`, or `MacOS` -## Example +## Configure rule To check whether your script is compatible with PowerShell Core 6.1 on Windows, add this configuration: @@ -61,5 +63,14 @@ name under `compatibility`. The `core-6.0.2-*` files were removed in PSScriptAnalyzer 1.18 because PowerShell 6.0 reached its end of life. +While the rule is configurable, the rule is always enabled. Use one of the following methods to +avoid using this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: https://github.com/PowerShell/PSScriptAnalyzer/blob/main/Utils/New-CommandDataFile.ps1 +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCommands.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCommands.md index 0624a19..acfe99f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCommands.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleCommands.md @@ -1,6 +1,6 @@ --- description: Use compatible commands -ms.date: 06/09/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCompatibleCommands --- @@ -8,6 +8,8 @@ title: UseCompatibleCommands **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects commands that aren't available on your targeted PowerShell platform. @@ -132,29 +134,6 @@ function Get-OsInfo { } ``` -## Suppression - -As with other rules, you can suppress command compatibility diagnostics by adding a suppression -attribute to the `param` block of a scriptblock. - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] -``` - -You can also suppress the rule for specific commands: - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', - 'Start-Service')] -``` - -You can also suppress it for specific parameters: - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', - 'Import-Module/FullyQualifiedName')] -``` - ## Parameters ### Enable @@ -182,3 +161,26 @@ command-name strings. The default value is `@()`. [01]: https://github.com/PowerShell/PSScriptAnalyzer/tree/main/PSCompatibilityCollector [02]: https://github.com/PowerShell/PSScriptAnalyzer/tree/main/PSCompatibilityCollector/optional_profiles + +## Suppression + +As with other rules, you can suppress command compatibility diagnostics by adding a suppression +attribute to the `param` block of a scriptblock. + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] +``` + +You can also suppress the rule for specific commands: + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', + 'Start-Service')] +``` + +You can also suppress it for specific parameters: + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', + 'Import-Module/FullyQualifiedName')] +``` diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleSyntax.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleSyntax.md index aa1f245..98229df 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleSyntax.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleSyntax.md @@ -1,6 +1,6 @@ --- description: Use compatible syntax -ms.date: 06/09/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCompatibleSyntax --- @@ -8,6 +8,8 @@ title: UseCompatibleSyntax **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects syntax elements that aren't compatible with your specified PowerShell target diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md index e50822d..658a5a3 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCompatibleTypes.md @@ -1,6 +1,6 @@ --- description: Use compatible types -ms.date: 06/09/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCompatibleTypes --- @@ -8,6 +8,8 @@ title: UseCompatibleTypes **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects types that aren't available by default on your targeted PowerShell platforms. @@ -154,29 +156,6 @@ PSUseCompatibleTypes Warning 1 The type 'System.Managemen '5.1.17763.316' on platform 'Microsoft Windows 10 Pro' ``` -## Suppression - -As with other rules, you can suppress type compatibility diagnostics by adding a suppression -attribute to the `param` block of a scriptblock. - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', '')] -``` - -You can also suppress the rule for specific types: - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', - 'System.Management.Automation.Security.SystemPolicy')] -``` - -You can also suppress it for specific type members: - -```powershell -[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', - 'System.Management.Automation.LanguagePrimitives/ConvertTypeNameToPSTypeName')] -``` - ## Parameters ### Enable @@ -204,3 +183,26 @@ checks. It accepts an array of type-name strings. The default value is `@()`. [01]: https://github.com/PowerShell/PSScriptAnalyzer/tree/main/PSCompatibilityCollector [02]: https://github.com/PowerShell/PSScriptAnalyzer/tree/main/PSCompatibilityCollector/optional_profiles + +## Suppression + +As with other rules, you can suppress type compatibility diagnostics by adding a suppression +attribute to the `param` block of a scriptblock. + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', '')] +``` + +You can also suppress the rule for specific types: + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', + 'System.Management.Automation.Security.SystemPolicy')] +``` + +You can also suppress it for specific type members: + +```powershell +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleTypes', + 'System.Management.Automation.LanguagePrimitives/ConvertTypeNameToPSTypeName')] +``` diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentIndentation.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentIndentation.md index 1bf186e..5e63927 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentIndentation.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentIndentation.md @@ -1,6 +1,6 @@ --- description: Use consistent indentation -ms.date: 06/09/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseConsistentIndentation --- @@ -8,10 +8,12 @@ title: UseConsistentIndentation **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects inconsistent indentation patterns within a source file. Indentation should be -consistent throughout your script. This rule is **disabled** by default. +consistent throughout your script. ## Example diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md index 4eaaef7..9665f21 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParameterSetName.md @@ -1,6 +1,6 @@ --- description: Use consistent parameter set names and proper parameter set configuration -ms.date: 06/09/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseConsistentParameterSetName --- @@ -9,6 +9,8 @@ title: UseConsistentParameterSetName **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects inconsistent parameter set naming and configuration issues that can cause runtime @@ -122,7 +124,7 @@ function Get-Data { } ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md index 60d36ea..acb5abf 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md @@ -1,6 +1,6 @@ --- description: Use the same pattern when defining parameters -ms.date: 06/10/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseConsistentParametersKind --- @@ -8,6 +8,8 @@ title: UseConsistentParametersKind **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects when functions don't consistently use the same pattern for defining parameters. @@ -34,3 +36,20 @@ function g { return } ``` + +## Configure rule + +```powershell +Rules = @{ + PSUseConsistentParametersKind = @{ + Enable = $true + } +} +``` + +## Parameters + +### Enable + +This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a +boolean value. To enable this rule, set this parameter to `$true`. The default value is `$false`. diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentWhitespace.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentWhitespace.md index 5531d2e..6a488dd 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentWhitespace.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentWhitespace.md @@ -1,6 +1,6 @@ --- description: Use consistent whitespace in PowerShell code -ms.date: 06/10/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseConsistentWhitespace --- @@ -8,6 +8,8 @@ title: UseConsistentWhitespace **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects inconsistent or redundant whitespace around braces, parentheses, operators, diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConstrainedLanguageMode.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConstrainedLanguageMode.md index ca2a3b6..ff32be8 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConstrainedLanguageMode.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConstrainedLanguageMode.md @@ -1,6 +1,6 @@ --- description: Use patterns compatible with Constrained Language Mode (CLM) -ms.date: 06/10/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseConstrainedLanguageMode --- @@ -8,6 +8,8 @@ title: UseConstrainedLanguageMode **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects PowerShell patterns that are restricted or not permitted in Constrained Language diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md index f82f51c..7baa07b 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseCorrectCasing.md @@ -1,6 +1,6 @@ --- description: Use exact casing for cmdlet names, functions, and parameters -ms.date: 06/10/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseCorrectCasing --- @@ -8,6 +8,8 @@ title: UseCorrectCasing **Severity Level: Information** +**Default state: Disabled** + ## Description This rule detects inconsistent casing in cmdlet names, parameters, type names, keywords, and @@ -46,7 +48,7 @@ foreach ($file in Get-ChildItem -Recurse) { Invoke-Command { 'foo' } -RunAsAdministrator ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseDeclaredVarsMoreThanAssignments.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseDeclaredVarsMoreThanAssignments.md index 8a86d1d..a290689 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseDeclaredVarsMoreThanAssignments.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseDeclaredVarsMoreThanAssignments.md @@ -1,6 +1,6 @@ --- description: Detect variables that are assigned but never used -ms.date: 06/10/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseDeclaredVarsMoreThanAssignments --- @@ -8,6 +8,8 @@ title: UseDeclaredVarsMoreThanAssignments **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects variables that are assigned a value but never used. A variable counts as "used" @@ -64,3 +66,16 @@ the `Write-Host` command. $errResult = $null Write-Host 'Ugh:' -ErrorVariable errResult ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseLiteralInitializerForHashtable.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseLiteralInitializerForHashtable.md index 584b96a..8c2c06e 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseLiteralInitializerForHashtable.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseLiteralInitializerForHashtable.md @@ -1,6 +1,6 @@ --- description: Create hashtables with literal initializers -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseLiteralInitializerForHashtable --- @@ -8,6 +8,8 @@ title: UseLiteralInitializerForHashtable **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects hashtables created using the `[hashtable]::new()` method or the `New-Object @@ -31,3 +33,16 @@ $hashtable = [hashtable]::new() ```powershell $hashtable = @{} ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md \ No newline at end of file diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseOutputTypeCorrectly.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseOutputTypeCorrectly.md index 9854cdf..bd68627 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseOutputTypeCorrectly.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseOutputTypeCorrectly.md @@ -1,6 +1,6 @@ --- description: Use the OutputType attribute correctly -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseOutputTypeCorrectly --- @@ -8,6 +8,8 @@ title: UseOutputTypeCorrectly **Severity Level: Information** +**Default state: Always enabled** + ## Description This rule detects when a function or script returns a different type than what is declared in the @@ -47,5 +49,16 @@ function Get-Foo } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + [01]: /powershell/module/microsoft.powershell.core/about/about_functions_outputtypeattribute +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UsePSCredentialType.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UsePSCredentialType.md index 5519763..891b8fb 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UsePSCredentialType.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UsePSCredentialType.md @@ -1,6 +1,6 @@ --- description: Use PSCredential type -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UsePSCredentialType --- @@ -8,6 +8,8 @@ title: UsePSCredentialType **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when a cmdlet or function defines a **Credential** parameter with a type other @@ -34,3 +36,16 @@ function Credential([PSCredential]$Credential) ... } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseProcessBlockForPipelineCommand.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseProcessBlockForPipelineCommand.md index 8c12c0a..1167238 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseProcessBlockForPipelineCommand.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseProcessBlockForPipelineCommand.md @@ -1,6 +1,6 @@ --- description: Use process block for commands that accept input from a pipeline -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseProcessBlockForPipelineCommand --- @@ -8,6 +8,8 @@ title: UseProcessBlockForPipelineCommand **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects functions with pipeline-enabled parameters that handle input directly in the @@ -52,3 +54,16 @@ Function Get-Number } } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseShouldProcessForStateChangingFunctions.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseShouldProcessForStateChangingFunctions.md index 8c57188..cd3c5e8 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseShouldProcessForStateChangingFunctions.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseShouldProcessForStateChangingFunctions.md @@ -1,6 +1,6 @@ --- description: Use ShouldProcess for state changing functions -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseShouldProcessForStateChangingFunctions --- @@ -8,6 +8,8 @@ title: UseShouldProcessForStateChangingFunctions **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects functions with state-changing verbs that don't support `ShouldProcess`. Functions @@ -66,6 +68,16 @@ function Set-ServiceObject } ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][05]. + ## See also - [about_Functions_CmdletBindingAttribute][01] @@ -78,3 +90,4 @@ function Set-ServiceObject [02]: /powershell/scripting/developer/cmdlet/requesting-confirmation-from-cmdlets [03]: /powershell/scripting/developer/cmdlet/required-development-guidelines#support-confirmation-requests-rd04 [04]: /powershell/scripting/learn/deep-dives/everything-about-shouldprocess +[05]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingleValueFromPipelineParameter.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingleValueFromPipelineParameter.md index 8796054..f9321d1 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingleValueFromPipelineParameter.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingleValueFromPipelineParameter.md @@ -1,6 +1,6 @@ --- description: Use a single ValueFromPipeline parameter per parameter set -ms.date: 06/25/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseSingleValueFromPipelineParameter --- @@ -8,6 +8,8 @@ title: UseSingleValueFromPipelineParameter **Severity Level: Warning** +**Default state: Disabled** + ## Description This rule detects functions where multiple parameters within the same parameter set are marked as @@ -57,6 +59,23 @@ function Process-Data { } ``` +## Configure rule + +```powershell +Rules = @{ + PSUseSingleValueFromPipelineParameter = @{ + Enable = $true + } +} +``` + +## Parameters + +### Enable + +This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a +boolean value. To enable this rule, set this parameter to `$true`. The default value is `$false`. + ## Suppression This rule is disabled by default. If you have enabled it in your configuration but want to suppress diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md index 172503c..8934595 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md @@ -1,6 +1,6 @@ --- description: Use single cmdlet nouns -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseSingularNouns --- @@ -8,6 +8,8 @@ title: UseSingularNouns **Severity Level: Warning** +**Default state: Enabled** + ## Description This rule detects cmdlet names that use plural nouns instead of singular nouns. @@ -46,7 +48,7 @@ function Get-File } ``` -## Configuration +## Configure rule ```powershell Rules = @{ diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSupportsShouldProcess.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSupportsShouldProcess.md index 24ce3d8..fd50e4f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSupportsShouldProcess.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSupportsShouldProcess.md @@ -1,6 +1,6 @@ --- description: Use SupportsShouldProcess -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseSupportsShouldProcess --- @@ -8,6 +8,8 @@ title: UseSupportsShouldProcess **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects manual declarations of `WhatIf` and `Confirm` parameters in functions and cmdlets. @@ -42,3 +44,16 @@ function foo { ) } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseToExportFieldsInManifest.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseToExportFieldsInManifest.md index 3dfe435..ed76699 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseToExportFieldsInManifest.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseToExportFieldsInManifest.md @@ -1,6 +1,6 @@ --- description: Use the *ToExport module manifest fields -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseToExportFieldsInManifest --- @@ -8,6 +8,8 @@ title: UseToExportFieldsInManifest **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when module manifests use wildcards (`'*'`) or null (`$null`) in export fields. To @@ -36,3 +38,16 @@ FunctionsToExport = $null ```powershell FunctionsToExport = @() ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUTF8EncodingForHelpFile.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUTF8EncodingForHelpFile.md index b5063d6..277afbf 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUTF8EncodingForHelpFile.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUTF8EncodingForHelpFile.md @@ -1,6 +1,6 @@ --- description: Use UTF8 encoding for help file -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseUTF8EncodingForHelpFile --- @@ -8,6 +8,8 @@ title: UseUTF8EncodingForHelpFile **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when an `about_` help file doesn't use UTF-8 encoding. The rule verifies that help @@ -51,11 +53,28 @@ SHORT DESCRIPTION $helpText | Set-Content -Path "about_Contoso.help.txt" -Encoding utf8NoBOM ``` +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][01]. + ## See also For more information, see the following articles: -- [System.IO.StreamReader](/dotnet/api/system.io.streamreader.currentencoding) -- [about_Character_Encoding](/powershell/module/microsoft.powershell.core/about/about_character_encoding) -- [Set-Content](/powershell/module/microsoft.powershell.management/set-content) -- [Understanding file encoding in Visual Studio Code and PowerShell](/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding) +- [System.IO.StreamReader][02] +- [about_Character_Encoding][03] +- [Set-Content][04] +- [Understanding file encoding in Visual Studio Code and PowerShell][05] + + +[01]: ../using-scriptanalyzer.md +[02]: /dotnet/api/system.io.streamreader.currentencoding +[03]: /powershell/module/microsoft.powershell.core/about/about_character_encoding +[04]: /powershell/module/microsoft.powershell.management/set-content +[05]: /powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUsingScopeModifierInNewRunspaces.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUsingScopeModifierInNewRunspaces.md index 9245c32..a129e7f 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUsingScopeModifierInNewRunspaces.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseUsingScopeModifierInNewRunspaces.md @@ -1,6 +1,6 @@ --- description: Use the '$using:' scope modifier in runspace scriptblocks -ms.date: 06/11/2026 +ms.date: 07/21/2026 ms.topic: reference title: UseUsingScopeModifierInNewRunspaces --- @@ -8,6 +8,8 @@ title: UseUsingScopeModifierInNewRunspaces **Severity Level: Warning** +**Default state: Always enabled** + ## Description This rule detects when scriptblocks running in new runspaces reference parent scope variables @@ -41,3 +43,16 @@ $var = 'foo' $var = 'foo' 1..2 | ForEach-Object -Parallel { $using:var } ``` + +## Configure rule + +This rule is always enabled and isn't configurable. Use one of the following methods to avoid using +this rule: + +- Create a custom rule configuration file to include only the rules you want or exclude the rules + you don't want. +- Add the appropriate rule suppression attributes to your code to suppress the rule for specific + code blocks. For more information, see the _Suppressing rules_ section of [Using PSScriptAnalyzer][02]. + + +[02]: ../using-scriptanalyzer.md