Skip to content

PSUseCmdletCorrectly breaks on Write-Verbose -Verbose #1624

Open
@Jaykul

Description

@Jaykul

I'm getting a rule violation when we force Write-Verbose to have output like this:

Write-Verbose -Verbose "My Message"

Steps to reproduce

Invoke-ScriptAnalyzer -ScriptDefinition '
Write-Verbose -Verbose "Getting file list from $pwd"
Write-Warning -Verbose "Getting file list from $pwd"
Write-Error -Verbose "Getting file list from $pwd"
Write-Error -ErrorAction SilentlyContinue "Getting file list from $pwd"
' -IncludeRule PSUseCmdletCorrectly

Expected behavior

There are no violations.

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseCmdletCorrectly                Warning                 2     Cmdlet 'Write-Verbose' may be used incorrectly. Please
                                                                  check that all mandatory parameters are supplied.
PSUseCmdletCorrectly                Warning                 3     Cmdlet 'Write-Warning' may be used incorrectly. Please
                                                                  check that all mandatory parameters are supplied.

I think it's significant that it has no problem with either of the Write-Error lines, but I have not looked at the code to understand what is happening ...

Environment data

> $PSVersionTable

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.18362.1171                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.18362.1171                                                                         
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.19.1
1.19.1

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