From aa2890aa537c941d6ea45b2d17f094d095340158 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 23 Jul 2026 10:36:52 -0500 Subject: [PATCH 1/4] Fix typos and formatting (#443) --- .../PSScriptAnalyzer/Invoke-ScriptAnalyzer.md | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md b/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md index 35b194b5..721d15f5 100644 --- a/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md +++ b/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml Module Name: PSScriptAnalyzer -ms.date: 10/07/2021 +ms.date: 07/23/2026 online version: https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer?view=ps-modules&wt.mc_id=ps-gethelp schema: 2.0.0 --- @@ -107,7 +107,12 @@ This example runs all rules except for **PSAvoidUsingCmdletAliases** and subdirectories. ```powershell -Invoke-ScriptAnalyzer -Path C:\ps-test\MyModule -Recurse -ExcludeRule PSAvoidUsingCmdletAliases, PSAvoidUsingInternalURLs +$invokeScriptAnalyzerSplat = @{ + Path = 'C:\ps-test\MyModule' + Recurse = $true + ExcludeRule = 'PSAvoidUsingCmdletAliases', 'PSAvoidUsingInternalURLs' +} +Invoke-ScriptAnalyzer @invokeScriptAnalyzerSplat ``` ### EXAMPLE 5 - Run Script Analyzer with custom rules @@ -116,13 +121,19 @@ This example runs Script Analyzer on `Test-Script.ps1` with the standard rules a `C:\CommunityAnalyzerRules` path. ```powershell -Invoke-ScriptAnalyzer -Path D:\test_scripts\Test-Script.ps1 -CustomRulePath C:\CommunityAnalyzerRules -IncludeDefaultRules +$invokeScriptAnalyzerSplat = @{ + Path = 'D:\test_scripts\Test-Script.ps1' + CustomRulePath = 'C:\CommunityAnalyzerRules' + IncludeDefaultRules = $true +} +Invoke-ScriptAnalyzer @invokeScriptAnalyzerSplat ``` ### EXAMPLE 6 - Run only the rules that are Error severity and have the PSDSC source name ```powershell -$DSCError = Get-ScriptAnalyzerRule -Severity Error | Where SourceName -eq PSDSC +$DSCError = Get-ScriptAnalyzerRule -Severity Error | + Where-Object SourceName -eq PSDSC $Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule" Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse ``` @@ -145,10 +156,11 @@ function Get-Widgets { [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")] - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingCmdletAliases", "", Justification="Resolution in progress.")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingCmdletAliases", "", + Justification="Resolution in progress.")] Param() - dir $pshome + dir $PSHOME ... } @@ -156,10 +168,9 @@ Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 ``` ```Output -RuleName Severity FileName Line Message --------- -------- -------- ---- ------- -PSProvideCommentHelp Information ManageProf 14 The cmdlet 'Get-Widget' does not have a help comment. - iles.psm1 +RuleName Severity FileName Line Message +-------- -------- -------- ---- ------- +PSProvideCommentHelp Information ManageProfiles.psm1 14 The cmdlet 'Get-Widget' does not have a help comment. ``` ```powershell @@ -167,12 +178,10 @@ Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 -SuppressedOnly ``` ```Output -Rule Name Severity File Name Line Justification ---------- -------- --------- ---- ------------- -PSAvoidUsingCmdletAliases Warning ManageProf 21 Resolution in progress. - iles.psm1 -PSUseSingularNouns Warning ManageProf 14 - iles.psm1 +Rule Name Severity File Name Line Justification +--------- -------- --------- ---- ------------- +PSAvoidUsingCmdletAliases Warning ManageProfiles.psm1 21 Resolution in progress. +PSUseSingularNouns Warning ManageProfiles.psm1 14 ``` The second command uses the **SuppressedOnly** parameter to report violations of the rules that are @@ -192,7 +201,7 @@ value of the **Profile** parameter is the path to the Script Analyzer profile. ExcludeRules = '*WriteHost' } -Invoke-ScriptAnalyzer -Path $pshome\Modules\BitLocker -Settings .\ScriptAnalyzerProfile.txt +Invoke-ScriptAnalyzer -Path $PSHOME\Modules\BitLocker -Settings .\ScriptAnalyzerProfile.txt ``` If you include a conflicting parameter in the `Invoke-ScriptAnalyzer` command, such as @@ -208,15 +217,16 @@ Invoke-ScriptAnalyzer -ScriptDefinition "function Get-Widgets {Write-Host 'Hello ``` ```Output -RuleName Severity FileName Line Message --------- -------- -------- ---- ------- -PSAvoidUsingWriteHost Warning 1 Script - because - there i - suppres - Write-O -PSUseSingularNouns Warning 1 The cmd - noun sh +RuleName Severity FileName Line Message +-------- -------- -------- ---- ------- +PSAvoidUsingWriteHost Warning 1 Script definition uses Write-Host. Avoid using + Write-Host because it might not work in all hosts, + does not work when there is no host, and (prior + to PS 5.0) cannot be suppressed, captured, or + redirected. Instead, use Write-Output, Write-Verbose, + or Write-Information. +PSUseSingularNouns Warning 1 The cmdlet 'Get-Widgets' uses a plural noun. A + singular noun should be used instead. ``` When you use the **ScriptDefinition** parameter, the **FileName** property of the @@ -536,15 +546,13 @@ Valid values are: - Error - Warning -- Information. - -You can specify one ore more severity values. +- Information +- ParseError -The parameter filters the rules violations only after running all rules. To filter rules -efficiently, use `Get-ScriptAnalyzerRule` to select the rules you want to run. +You can specify one or more severity values. -The **Severity** parameter takes precedence over **IncludeRule**. For example, if **Severity** is -`Error`, you cannot use **IncludeRule** to include a `Warning` rule. +The parameter filters the rules violations only after running all rules, regardless of severity. To +filter rules efficiently, use `Get-ScriptAnalyzerRule` to select the rules you want to run. ```yaml Type: String[] From 038862dc5356870f19b777f92b0bb969805de882 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 23 Jul 2026 12:24:14 -0500 Subject: [PATCH 2/4] Clarify what -Severity parameter filters (#444) * Clarify what -Severity parameter filters * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md b/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md index 721d15f5..f1350a26 100644 --- a/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md +++ b/reference/ps-modules/PSScriptAnalyzer/Invoke-ScriptAnalyzer.md @@ -551,8 +551,9 @@ Valid values are: You can specify one or more severity values. -The parameter filters the rules violations only after running all rules, regardless of severity. To -filter rules efficiently, use `Get-ScriptAnalyzerRule` to select the rules you want to run. +The parameter filters the rule violation output only after running all rules. It doesn't filter +which rules are run. To filter rules efficiently, use `Get-ScriptAnalyzerRule` to select the rules +you want to run. ```yaml Type: String[] From c52c5cfd8695a89a13f796da8518f03756223572 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 23 Jul 2026 13:47:51 -0500 Subject: [PATCH 3/4] Sync PSSA docs changes from repo (#445) --- .../Rules/UseConsistentParametersKind.md | 9 ++++++++- .../PSScriptAnalyzer/Rules/UseSingularNouns.md | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md index acb5abfc..1ddc79d8 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: 07/21/2026 +ms.date: 07/23/2026 ms.topic: reference title: UseConsistentParametersKind --- @@ -43,6 +43,7 @@ function g { Rules = @{ PSUseConsistentParametersKind = @{ Enable = $true + ParametersKind = 'ParamBlock' } } ``` @@ -53,3 +54,9 @@ Rules = @{ 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`. + +## ParametersKind + +Use this parameter to specify the type of parameter definition pattern that should be used +consistently across all functions. It accepts a string value, which can be either `Inline` or +`ParamBlock`. The default value is `ParamBlock`. diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md index 8934595e..c38bae02 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md @@ -68,6 +68,6 @@ boolean value. To disable this rule, set this parameter to `$false`. The default ### NounAllowList -This parameter specifies which noun commands to exclude from this rule. It accepts a string value. +This parameter specifies which noun commands to exclude from this rule. It accepts a string array. Both `Data` and `Windows` are common false positives and excluded by default. Default values are `'Data'` and `'Windows'`. From 1894b8ac0dcb13c1412f4a1b8e539c5f93ec0bc8 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Thu, 23 Jul 2026 13:57:14 -0500 Subject: [PATCH 4/4] Fix typos (#446) --- .../PSScriptAnalyzer/Rules/UseConsistentParametersKind.md | 2 +- .../PSScriptAnalyzer/Rules/UseSingularNouns.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md index 1ddc79d8..f64ae974 100644 --- a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md +++ b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md @@ -55,7 +55,7 @@ Rules = @{ 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`. -## ParametersKind +### ParametersKind Use this parameter to specify the type of parameter definition pattern that should be used consistently across all functions. It accepts a string value, which can be either `Inline` or diff --git a/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md b/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseSingularNouns.md index c38bae02..231dc418 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: 07/21/2026 +ms.date: 07/23/2026 ms.topic: reference title: UseSingularNouns --- @@ -68,6 +68,6 @@ boolean value. To disable this rule, set this parameter to `$false`. The default ### NounAllowList -This parameter specifies which noun commands to exclude from this rule. It accepts a string array. +This parameter specifies which command nouns to exclude from this rule. It accepts a string array. Both `Data` and `Windows` are common false positives and excluded by default. Default values are `'Data'` and `'Windows'`.