Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use at most a single ValueFromPipeline parameter per parameter set.
ms.date: 03/20/2026
description: Use a single ValueFromPipeline parameter per parameter set
ms.date: 06/11/2026
ms.topic: reference
title: UseSingleValueFromPipelineParameter
---
Expand All @@ -10,19 +10,17 @@ title: UseSingleValueFromPipelineParameter

## Description

Parameter sets should have at most one parameter marked as `ValueFromPipeline = true`.
This rule detects functions where multiple parameters within the same parameter set are marked as
accepting pipeline input by value. Parameter sets should have at most one parameter with
`ValueFromPipeline = true`.

This rule identifies functions where multiple parameters within the same parameter set have
`ValueFromPipeline` set to `true` (either explicitly or implicitly).

## How

Ensure that only one parameter per parameter set accepts pipeline input by value. If you need
multiple parameters to accept different types of pipeline input, use separate parameter sets.
When you need multiple parameters to accept different types of pipeline input, use separate
parameter sets instead. Each parameter set can have its own single `ValueFromPipeline` parameter,
but you can't have more than one within the same parameter set.

## Example

### Wrong
### Noncompliant

```powershell
function Process-Data {
Expand All @@ -41,8 +39,7 @@ function Process-Data {
}
```


### Correct
### Compliant

```powershell
function Process-Data {
Expand Down Expand Up @@ -91,9 +88,9 @@ For the default parameter set, use `'default'` as the suppression target:
## Notes

- This rule applies to both explicit `ValueFromPipeline = $true` and implicit `ValueFromPipeline`
(which is the same as using `= $true`)
- Parameters with `ValueFromPipeline=$false` are not flagged by this rule
(which is the same as using `= $true`).
- This rule doesn't flag parameters with `ValueFromPipeline = $false`.
- The rule correctly handles the default parameter set (`__AllParameterSets`) and named parameter
sets
sets.
- Different parameter sets can each have their own single `ValueFromPipeline` parameter without
triggering this rule
triggering this rule.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Cmdlet Singular Noun
ms.date: 03/27/2024
description: Use single cmdlet nouns
ms.date: 06/11/2026
ms.topic: reference
title: UseSingularNouns
---
Expand All @@ -10,8 +10,14 @@ title: UseSingularNouns

## Description

PowerShell team best practices state cmdlets should use singular nouns and not plurals. Suppression
allows you to suppress the rule for specific function names. For example:
This rule detects cmdlet names that use plural nouns instead of singular nouns.

PowerShell best practices require that cmdlets use singular nouns, not plurals. You can use the
`NounAllowList` parameter to exclude specific nouns from this rule, or suppress the rule for
individual functions using `SuppressMessageAttribute`. If a violation is found, change the plural
noun to its singular form.

For example:

```
function Get-Elements {
Expand All @@ -20,35 +26,9 @@ function Get-Elements {
}
```

## Configuration

```powershell
Rules = @{
PSUseSingularNouns = @{
Enable = $true
NounAllowList = 'Data', 'Windows', 'Foos'
}
}
```

### Parameters

- `Enable`: `bool` (Default value is `$true`)

Enable or disable the rule during ScriptAnalyzer invocation.

- `NounAllowList`: `string[]` (Default value is `{'Data', 'Windows'}`)

Commands to be excluded from this rule. `Data` and `Windows` are common false positives and are
excluded by default.

## How

Change plurals to singular.

## Example

### Wrong
### Noncompliant

```powershell
function Get-Files
Expand All @@ -57,11 +37,35 @@ function Get-Files
}
```

### Correct
### Compliant

```powershell
function Get-File
{
...
}
```

## Configuration

```powershell
Rules = @{
PSUseSingularNouns = @{
Enable = $true
NounAllowList = 'Data', 'Windows', 'Foos'
}
}
```

## Parameters

### Enable

This parameter controls whether ScriptAnalyzer checks the code against this rule. It accepts a
boolean value. To disable this rule, set this parameter to `$false`. The default value is `$true`.

### NounAllowList

This parameter specifies which noun commands to exclude from this rule. It accepts a string value.
Both `Data` and `Windows` are common false positives and excluded by default. Default values are
`'Data'` and `'Windows'`.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use SupportsShouldProcess
ms.date: 06/28/2023
ms.date: 06/11/2026
ms.topic: reference
title: UseSupportsShouldProcess
---
Expand All @@ -10,15 +10,17 @@ title: UseSupportsShouldProcess

## Description

This rule discourages manual declaration of `WhatIf` and `Confirm` parameters in a function/cmdlet.
These parameters are, however, provided automatically when a function declares a `CmdletBinding`
attribute with `SupportsShouldProcess` as its named argument. Using `SupportsShouldProcess` not only
provides these parameters but also some generic functionality that allows the function/cmdlet
authors to provide the desired interactive experience while using the cmdlet.
This rule detects manual declarations of `WhatIf` and `Confirm` parameters in functions and cmdlets.
Rather than manually declaring these parameters, you should use the `CmdletBinding` attribute with
`SupportsShouldProcess` as a named argument.

This approach automatically provides both parameters along with built-in functionality that gives
you and your users a consistent interactive experience. Using `SupportsShouldProcess` is more
maintainable and provides standard behavior without extra code.

## Example

### Wrong
### Noncompliant

```powershell
function foo {
Expand All @@ -30,7 +32,7 @@ function foo {
}
```

### Correct
### Compliant

```powershell
function foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use the *ToExport module manifest fields.
ms.date: 06/28/2023
description: Use the *ToExport module manifest fields
ms.date: 06/11/2026
ms.topic: reference
title: UseToExportFieldsInManifest
---
Expand All @@ -10,50 +10,28 @@ title: UseToExportFieldsInManifest

## Description

To improve the performance of module auto-discovery, module manifests should not use wildcards
(`'*'`) or null (`$null`) in the following entries:
This rule detects when module manifests use wildcards (`'*'`) or null (`$null`) in export fields. To
improve module autodiscovery performance, module manifests shouldn't use wildcards or null in the
following entries:

- `AliasesToExport`
- `CmdletsToExport`
- `FunctionsToExport`
- `VariablesToExport`

Using wildcards or null has causes PowerShell to perform expensive work to analyze a module during
module auto-discovery.
When you use wildcards or null, PowerShell performs expensive analysis of your module during
autodiscovery. Instead, use an explicit list of items to export.

## How
## Example

Use an explicit list in the entries.

## Example 1

Suppose there are no functions in your module to export. Then,

### Wrong
### Noncompliant

```powershell
FunctionsToExport = $null
```

### Correct

```powershell
FunctionToExport = @()
```

## Example 2

Suppose there are only two functions in your module, `Get-Foo` and `Set-Foo` that you want to
export. Then,

### Wrong

```powershell
FunctionsToExport = '*'
```

### Correct
### Compliant

```powershell
FunctionToExport = @(Get-Foo, Set-Foo)
FunctionsToExport = @()
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use UTF8 Encoding For Help File
ms.date: 01/07/2025
description: Use UTF8 encoding for help file
ms.date: 06/11/2026
ms.topic: reference
title: UseUTF8EncodingForHelpFile
---
Expand All @@ -10,24 +10,52 @@ title: UseUTF8EncodingForHelpFile

## Description

Check that an `about_` help file uses UTF-8 encoding. The filename must start with `about_` and end
with `.help.txt`. The rule uses the **CurrentEncoding** property of the **StreamReader** class to
determine the encoding of the file.
This rule detects when an `about_` help file doesn't use UTF-8 encoding. The rule verifies that help
files starting with `about_` and ending with `.help.txt` are saved in UTF-8 encoding. It uses the
**CurrentEncoding** property of the **StreamReader** class to check the file's encoding.

## How
To ensure your help files use the correct encoding, follow these guidelines:

For PowerShell commands that write to files, ensure that you set the encoding parameter to `utf8`,
`utf8BOM`, or `utf8NoBOM`.
- When using PowerShell commands to write to files, set the encoding parameter to `utf8`, `utf8BOM`,
or `utf8NoBOM`.
- When creating or editing help files in a text editor, configure it to save files in UTF-8 format.
Consult your editor's documentation for instructions on setting the file encoding.

When you create a help file using a text editor, ensure that the editor is configured to save the
file in a UTF8 format. Consult the documentation for your text editor for instructions on how to
save files with a specific encoding.
## Example

## Further reading
### Noncompliant

```powershell
$helpText = @'
TOPIC
about_Contoso

SHORT DESCRIPTION
Describes Contoso commands.
'@

$helpText | Set-Content -Path "about_Contoso.help.txt" -Encoding Unicode
```

### Compliant

```powershell
$helpText = @'
TOPIC
about_Contoso

SHORT DESCRIPTION
Describes Contoso commands.
'@

$helpText | Set-Content -Path "about_Contoso.help.txt" -Encoding utf8NoBOM
```

## See also

For more information, see the following articles:

- [System.IO.StreamReader](xref:System.IO.StreamReader.CurrentEncoding%2A)
- [System.IO.StreamReader](/dotnet/api/system.io.streamreader.currentencoding)
- [about_Character_Encoding](/powershell/module/microsoft.powershell.core/about/about_character_encoding)
- [Set-Content](xref:Microsoft.PowerShell.Management.Set-Content)
- [Understanding file encoding in VS Code and PowerShell](/powershell/scripting/dev-cross-plat/vscode/understanding-file-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)
Loading
Loading