Skip to content

PSUseSingularNouns Rule doesn't work in PowerShell Core but does in PowerShell #1626

Closed
@dpaulson45

Description

@dpaulson45

Steps to reproduce

Run the following in both PowerShell and PowerShell core

dpaul :: ~ » Invoke-ScriptAnalyzer -ScriptDefinition 'function Get-AllNics () { }'
dpaul :: ~ » Get-Module -Name PSScriptAnalyzer

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.19.1                PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAnalyzer}

dpaul :: ~ » $PSversionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      1      1

dpaul :: ~ »
PS C:\Windows\system32>  Invoke-ScriptAnalyzer -ScriptDefinition 'function Get-AllNics () { }'

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseSingularNouns                  Warning                 1     The cmdlet 'Get-AllNics' uses a plural noun. A singular
                                                                  noun should be used instead.


PS C:\Windows\system32> Get-Module -Name PSScriptAnalyzer

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.19.1     PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAnalyzer}


PS C:\Windows\system32> $PSversionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  610


PS C:\Windows\system32>

Expected behavior

Both types of PowerShell should invoke the same rules.

Actual behavior

PowerShell Core doesn't invoke the same rules like PowerShell. PSUseSingularNouns is the only one that I have found thus far.

Environment data

dpaul :: ~ » $PSversionTable

Name                           Value
----                           -----
PSVersion                      7.1.1
PSEdition                      Core
GitCommitId                    7.1.1
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
1.19.1
dpaul :: ~ » Get-Module -ListAvailable PSScriptAnalyzer

    Directory: C:\Users\dpaul\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.19.1                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.19.1                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}
PS C:\Windows\system32>  (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
PS C:\Windows\system32> $PSversionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Note sure if the PowerShell Core is supported, but it should be as that is what we appear to be moving to. Also not sure if the issue is partly because of the two modules somehow being loaded. Tried to remove them but wasn't working.

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