| description | Use the same pattern when defining parameters |
|---|---|
| ms.date | 07/23/2026 |
| ms.topic | reference |
| title | UseConsistentParametersKind |
Severity Level: Warning
Default state: Disabled
This rule detects when functions don't consistently use the same pattern for defining parameters.
All functions should use the same parameter definition pattern to enforce consistent code style
across the codebase. Rewrite any function that doesn't match the configured parameter definition
kind. In simple scenarios, both the Inline and ParamBlock function definition patterns are
functionally equivalent.
function f([Parameter()]$FirstParam) {
return
}function g {
param([Parameter()]$FirstParam)
return
}Rules = @{
PSUseConsistentParametersKind = @{
Enable = $true
ParametersKind = 'ParamBlock'
}
}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.
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.