Skip to content

Commit c0957d2

Browse files
committed
Sync docs changes from docs repo
1 parent 4b0117c commit c0957d2

85 files changed

Lines changed: 2934 additions & 1855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/Cmdlets/Invoke-Formatter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ schema: 2.0.0
99
# Invoke-Formatter
1010

1111
## SYNOPSIS
12+
1213
Formats a script text based on the input settings or default settings.
1314

1415
## SYNTAX

docs/Cmdlets/Invoke-ScriptAnalyzer.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml
33
Module Name: PSScriptAnalyzer
4-
ms.date: 10/07/2021
4+
ms.date: 07/23/2026
55
online version: https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer?view=ps-modules&wt.mc_id=ps-gethelp
66
schema: 2.0.0
77
---
@@ -107,7 +107,12 @@ This example runs all rules except for **PSAvoidUsingCmdletAliases** and
107107
subdirectories.
108108

109109
```powershell
110-
Invoke-ScriptAnalyzer -Path C:\ps-test\MyModule -Recurse -ExcludeRule PSAvoidUsingCmdletAliases, PSAvoidUsingInternalURLs
110+
$invokeScriptAnalyzerSplat = @{
111+
Path = 'C:\ps-test\MyModule'
112+
Recurse = $true
113+
ExcludeRule = 'PSAvoidUsingCmdletAliases', 'PSAvoidUsingInternalURLs'
114+
}
115+
Invoke-ScriptAnalyzer @invokeScriptAnalyzerSplat
111116
```
112117

113118
### 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
116121
`C:\CommunityAnalyzerRules` path.
117122

118123
```powershell
119-
Invoke-ScriptAnalyzer -Path D:\test_scripts\Test-Script.ps1 -CustomRulePath C:\CommunityAnalyzerRules -IncludeDefaultRules
124+
$invokeScriptAnalyzerSplat = @{
125+
Path = 'D:\test_scripts\Test-Script.ps1'
126+
CustomRulePath = 'C:\CommunityAnalyzerRules'
127+
IncludeDefaultRules = $true
128+
}
129+
Invoke-ScriptAnalyzer @invokeScriptAnalyzerSplat
120130
```
121131

122132
### EXAMPLE 6 - Run only the rules that are Error severity and have the PSDSC source name
123133

124134
```powershell
125-
$DSCError = Get-ScriptAnalyzerRule -Severity Error | Where SourceName -eq PSDSC
135+
$DSCError = Get-ScriptAnalyzerRule -Severity Error |
136+
Where-Object SourceName -eq PSDSC
126137
$Path = "$home\Documents\WindowsPowerShell\Modules\MyDSCModule"
127138
Invoke-ScriptAnalyzerRule -Path $Path -IncludeRule $DSCError -Recurse
128139
```
@@ -145,34 +156,32 @@ function Get-Widgets
145156
{
146157
[CmdletBinding()]
147158
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")]
148-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingCmdletAliases", "", Justification="Resolution in progress.")]
159+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingCmdletAliases", "",
160+
Justification="Resolution in progress.")]
149161
Param()
150162
151-
dir $pshome
163+
dir $PSHOME
152164
...
153165
}
154166
155167
Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1
156168
```
157169

158170
```Output
159-
RuleName Severity FileName Line Message
160-
-------- -------- -------- ---- -------
161-
PSProvideCommentHelp Information ManageProf 14 The cmdlet 'Get-Widget' does not have a help comment.
162-
iles.psm1
171+
RuleName Severity FileName Line Message
172+
-------- -------- -------- ---- -------
173+
PSProvideCommentHelp Information ManageProfiles.psm1 14 The cmdlet 'Get-Widget' does not have a help comment.
163174
```
164175

165176
```powershell
166177
Invoke-ScriptAnalyzer -Path .\Get-Widgets.ps1 -SuppressedOnly
167178
```
168179

169180
```Output
170-
Rule Name Severity File Name Line Justification
171-
--------- -------- --------- ---- -------------
172-
PSAvoidUsingCmdletAliases Warning ManageProf 21 Resolution in progress.
173-
iles.psm1
174-
PSUseSingularNouns Warning ManageProf 14
175-
iles.psm1
181+
Rule Name Severity File Name Line Justification
182+
--------- -------- --------- ---- -------------
183+
PSAvoidUsingCmdletAliases Warning ManageProfiles.psm1 21 Resolution in progress.
184+
PSUseSingularNouns Warning ManageProfiles.psm1 14
176185
```
177186

178187
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.
192201
ExcludeRules = '*WriteHost'
193202
}
194203
195-
Invoke-ScriptAnalyzer -Path $pshome\Modules\BitLocker -Settings .\ScriptAnalyzerProfile.txt
204+
Invoke-ScriptAnalyzer -Path $PSHOME\Modules\BitLocker -Settings .\ScriptAnalyzerProfile.txt
196205
```
197206

198207
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
208217
```
209218

210219
```Output
211-
RuleName Severity FileName Line Message
212-
-------- -------- -------- ---- -------
213-
PSAvoidUsingWriteHost Warning 1 Script
214-
because
215-
there i
216-
suppres
217-
Write-O
218-
PSUseSingularNouns Warning 1 The cmd
219-
noun sh
220+
RuleName Severity FileName Line Message
221+
-------- -------- -------- ---- -------
222+
PSAvoidUsingWriteHost Warning 1 Script definition uses Write-Host. Avoid using
223+
Write-Host because it might not work in all hosts,
224+
does not work when there is no host, and (prior
225+
to PS 5.0) cannot be suppressed, captured, or
226+
redirected. Instead, use Write-Output, Write-Verbose,
227+
or Write-Information.
228+
PSUseSingularNouns Warning 1 The cmdlet 'Get-Widgets' uses a plural noun. A
229+
singular noun should be used instead.
220230
```
221231

222232
When you use the **ScriptDefinition** parameter, the **FileName** property of the
@@ -513,7 +523,7 @@ following keys:
513523

514524
The keys and values in the profile are interpreted as if they were standard parameters and values of
515525
`Invoke-ScriptAnalyzer`, similar to splatting. For more information, see
516-
[about_Splatting](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_splatting).
526+
[about_Splatting](/powershell/module/microsoft.powershell.core/about/about_splatting).
517527

518528
```yaml
519529
Type: Object
@@ -536,15 +546,14 @@ Valid values are:
536546

537547
- Error
538548
- Warning
539-
- Information.
540-
541-
You can specify one ore more severity values.
549+
- Information
550+
- ParseError
542551

543-
The parameter filters the rules violations only after running all rules. To filter rules
544-
efficiently, use `Get-ScriptAnalyzerRule` to select the rules you want to run.
552+
You can specify one or more severity values.
545553

546-
The **Severity** parameter takes precedence over **IncludeRule**. For example, if **Severity** is
547-
`Error`, you cannot use **IncludeRule** to include a `Warning` rule.
554+
The parameter filters the rule violation output only after running all rules. It doesn't filter
555+
which rules are run. To filter rules efficiently, use `Get-ScriptAnalyzerRule` to select the rules
556+
you want to run.
548557

549558
```yaml
550559
Type: String[]

docs/Cmdlets/New-ScriptAnalyzerSettingsFile.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
---
22
external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml
33
Module Name: PSScriptAnalyzer
4-
ms.date: 04/17/2026
4+
ms.date: 07/21/2026
55
schema: 2.0.0
66
---
7-
87
# New-ScriptAnalyzerSettingsFile
98

109
## SYNOPSIS
10+
1111
Creates a new PSScriptAnalyzer settings file.
1212

1313
## SYNTAX
1414

1515
```
16-
New-ScriptAnalyzerSettingsFile [[-Path] <string>] [-BaseOnPreset <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
16+
New-ScriptAnalyzerSettingsFile [[-Path] <string>] [-BaseOnPreset <string>] [-Force]
17+
[-WhatIf] [-Confirm] [<CommonParameters>]
1718
```
1819

1920
## DESCRIPTION
2021

2122
The `New-ScriptAnalyzerSettingsFile` cmdlet creates a `PSScriptAnalyzerSettings.psd1` file in the
22-
specified directory.
23-
24-
When the **BaseOnPreset** parameter is provided, the generated file contains the rules and
25-
configuration defined by the given preset.
23+
specified directory. By default, the generated file includes all current rules in the `IncludeRules`
24+
list and populates the `Rules` section with all configurable properties, set to their default
25+
values.
2626

27-
When **BaseOnPreset** is not provided, the generated file includes all current rules in the
28-
`IncludeRules` list and populates the `Rules` section with all configurable properties, set to their
29-
default values.
27+
When you provide the **BaseOnPreset**, the generated file contains the rules and configuration
28+
defined by the given preset file.
3029

31-
If a settings file already exists at the target path, the cmdlet emits a terminating error unless
32-
the **Force** parameter is specified - in which case it's overwritten.
30+
If a settings file already exists at the target path the command fails unless you use the **Force**
31+
parameter to overwrite the existing file.
3332

3433
## EXAMPLES
3534

@@ -71,7 +70,8 @@ Shows what the cmdlet would do without actually writing the file.
7170

7271
### -Path
7372

74-
The directory where the settings file will be created. Defaults to the current working directory when not specified.
73+
The directory where the settings file is created. Defaults to the current working directory when not
74+
specified.
7575

7676
```yaml
7777
Type: String
@@ -104,7 +104,7 @@ Accept wildcard characters: False
104104
105105
### -WhatIf
106106
107-
Shows what would happen if the cmdlet runs. The cmdlet is not run.
107+
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
108108
109109
```yaml
110110
Type: SwitchParameter
@@ -172,7 +172,6 @@ The cmdlet returns a **FileInfo** object representing the created settings file.
172172
The output file is always named `PSScriptAnalyzerSettings.psd1` so that the automatic settings
173173
discovery in `Invoke-ScriptAnalyzer` picks it up when analysing scripts in the same directory.
174174

175-
Note: Relative paths in `CustomRulePath` are resolved from the caller's current working directory,
176175
Relative paths in `CustomRulePath` are resolved from the caller's current working directory,
177176
not from the location of the settings file. This matches `Invoke-ScriptAnalyzer` behavior.
178177

docs/Cmdlets/PSScriptAnalyzer.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Download Help Link: https://aka.ms/ps-modules-help
3-
Help Version: 1.25.0
3+
Help Version: 1.26.0
44
Locale: en-US
55
Module Guid: d6245802-193d-4068-a631-8863a4342a18
66
Module Name: PSScriptAnalyzer
@@ -31,3 +31,12 @@ Formats a script text based on the input settings or default settings.
3131
### [Invoke-ScriptAnalyzer](Invoke-ScriptAnalyzer.md)
3232

3333
Evaluates a script or module based on selected best practice rules
34+
35+
### [New-ScriptAnalyzerSettingsFile](New-ScriptAnalyzerSettingsFile.md)
36+
37+
Creates a new PSScriptAnalyzer settings file.
38+
39+
### [Test-ScriptAnalyzerSettingsFile](Test-ScriptAnalyzerSettingsFile.md)
40+
41+
Validates a PSScriptAnalyzer settings file as a self-contained unit.
42+

docs/Cmdlets/Test-ScriptAnalyzerSettingsFile.md

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
external help file: Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml
33
Module Name: PSScriptAnalyzer
4-
ms.date: 04/17/2026
4+
ms.date: 07/21/2026
55
schema: 2.0.0
66
---
7-
87
# Test-ScriptAnalyzerSettingsFile
98

109
## SYNOPSIS
10+
1111
Validates a PSScriptAnalyzer settings file as a self-contained unit.
1212

1313
## SYNTAX
@@ -25,19 +25,19 @@ see when given the same file.
2525

2626
The cmdlet verifies that:
2727

28-
- The file can be parsed as a PowerShell data file.
28+
- The file is parseable as a PowerShell data file
2929
- All rule names referenced in `IncludeRules`, `ExcludeRules`, and `Rules` correspond to known
30-
rules (wildcard patterns are skipped).
31-
- All `Severity` values are valid.
32-
- Rule option names in the `Rules` section correspond to actual configurable properties.
33-
- Rule option values that are constrained to a set of choices contain a valid value.
30+
rules (wildcard patterns are skipped)
31+
- All `Severity` values are valid
32+
- Rule option names in the `Rules` section correspond to actual configurable properties
33+
- Rule option values that are constrained to a set of choices contain a valid value
3434

35-
By default, when problems are found the cmdlet outputs a `DiagnosticRecord` for each one, with the
36-
source extent pointing to the offending text in the file. This is the same object type returned by
37-
`Invoke-ScriptAnalyzer`, so existing formatting and tooling works out of the box. When the file is
38-
valid, no output is produced.
35+
By default, the cmdlet outputs a `DiagnosticRecord` for each problem found. The source extent in the
36+
diagnostic record points to the offending text in the file. This is the same object type returned by
37+
`Invoke-ScriptAnalyzer`, so existing formatting and tooling works by default. When the file is
38+
valid, the command produces no output.
3939

40-
When `-Quiet` is specified the cmdlet returns only `$true` or `$false` and suppresses all
40+
If you use the **Quiet** parameter, the command only `$true` or `$false` and suppresses all
4141
diagnostic output.
4242

4343
## EXAMPLES
@@ -121,26 +121,18 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
121121

122122
### Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord
123123

124-
Without `-Quiet`, a `DiagnosticRecord` is output for each problem found. Each record includes the
125-
error message, the source extent (file, line and column), a severity, and the rule name
124+
Without the **Quiet** parameter, a `DiagnosticRecord` is output for each problem found. Each record
125+
includes the error message, the source extent (file, line and column), a severity, and the rule name
126126
`Test-ScriptAnalyzerSettingsFile`. No output is produced when the file is valid.
127127

128128
### System.Boolean
129129

130-
With `-Quiet`, returns `$true` when the file is valid and `$false` otherwise.
130+
With the **Quiet** parameter, returns `$true` when the file is valid and `$false` otherwise.
131131

132132
## NOTES
133133

134-
The cmdlet reads `CustomRulePath`, `RecurseCustomRulePath`, and `IncludeDefaultRules` from the
135-
settings file so it validates rule names against the same set of rules that `Invoke-ScriptAnalyzer`
136-
would load. This means the settings file is validated as a self-contained unit without requiring
137-
extra command-line parameters.
138-
139-
Note: Relative paths in `CustomRulePath` are resolved from the caller's current working directory,
140-
not from the location of the settings file. This matches `Invoke-ScriptAnalyzer` behaviour.
141-
142-
The `DiagnosticRecord` objects use the same type as `Invoke-ScriptAnalyzer`, so they benefit from
143-
the same default formatting and can be piped to the same downstream tooling.
134+
Relative paths in `CustomRulePath` are resolved from the caller's current working directory, not
135+
from the location of the settings file. This matches `Invoke-ScriptAnalyzer` behaviour.
144136

145137
## RELATED LINKS
146138

0 commit comments

Comments
 (0)