Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
powershell/PSUseConsistentParameterSetName is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | PSScriptAnalyzer |
| Auto-fix | No |
Description
Parameter set names in PowerShell are case-sensitive, unlike most other PowerShell elements. This rule ensures consistent casing and proper configuration of parameter sets to avoid runtime errors and improve code clarity. The rule performs five different checks:- Missing DefaultParameterSetName - Warns when parameter sets are used but no default is specified
- Multiple parameter declarations - Detects when a parameter is declared multiple times in the same parameter set. This is ultimately a runtime exception - this check helps catch it sooner.
- Case mismatch between DefaultParameterSetName and ParameterSetName - Ensures consistent casing
- Case mismatch between different ParameterSetName values - Ensures all references to the same parameter set use identical casing
- Parameter set names containing newlines - Warns against using newline characters in parameter set names
This rule isn’t enabled by default. The user needs to enable it through settings.
How
- Use a
DefaultParameterSetNamewhen defining multiple parameter sets - Ensure consistent casing between
DefaultParameterSetNameandParameterSetNamevalues - Use identical casing for all references to the same parameter set name
- Avoid declaring the same parameter multiple times in a single parameter set
- Do not use newline characters in parameter set names
Examples
Problematic code
Correct code
Configuration
Parameters
-
Enable: bool (Default value is$false) Enable or disable the rule during ScriptAnalyzer invocation.
Notes
- Parameter set names are case-sensitive in PowerShell, making this different from most other PowerShell elements
- The first occurrence of a parameter set name in your code is treated as the canonical casing
- Parameters without
[Parameter()]attributes are automatically part of all parameter sets - It’s a PowerShell best practice to always specify a
DefaultParameterSetNamewhen using parameter sets