Skip to content

Rule PSReservedParams generates Warning instead of Error #1973

Closed
@pulkownik1803

Description

@pulkownik1803

PSScriptAnalyzer reports PSReservedParams as warning but according to the documentation it's error

Steps to reproduce

function Test-Function {
    [CmdletBinding()]
    param (
        # Error
        [Parameter()]
        [string]
        $ErrorVariable
    )
    $ErrorVariable = 'Error'
}

> Invoke-ScriptAnalyzer -Path .\Test-Function.ps1

Expected behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSReservedParams                    Error        Test-Funct 5     'Test-Function' defines the reserved common parameter       
                                                 ion.ps1          'ErrorVariable'.

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSReservedParams                    Warning      Test-Funct 5     'Test-Function' defines the reserved common parameter       
                                                 ion.ps1          'ErrorVariable'.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions