PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

PSReviewUnusedParameter incorrectly triggered

Open DarkLite1 opened this issue 3 years ago • 0 comments

Steps to reproduce

Param (
    [String]$SamAccountName = 'bob'
)

Get-ADGroupMember 'group' | Get-ADUser | Where-Object {
        ($_.SamAccountName -ne $SamAccountName)
}

image

Expected behavior

The variable is clearly used in the script, so it shouldn't show the message.

Environment data

>  $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14393.5127
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.5127
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.20.0
1.19.1
1.19.0
1.18.3
1.20.0

Possibly related to #1472 , but there's no activity there anymore. So I thought I would bring this back to your attention.

DarkLite1 avatar Aug 11 '22 11:08 DarkLite1