PSUseSingularNouns Rule doesn't work in PowerShell Core but does in PowerShell
See original GitHub issueSteps 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
about Requires - PowerShell
The #Requires statement prevents a script from running unless the PowerShell version, modules (and version), or snap-ins (and version), ...
Read more >Invoke-ScriptAnalyzer (PSScriptAnalyzer) - PowerShell
Invoke-ScriptAnalyzer evaluates scripts or module files (.ps1, .psm1, and .psd1 files) based on a collection of best practice rules and returns objects that ......
Read more >Enable-PSRemoting (Microsoft.PowerShell.Core)
The Enable-PSRemoting cmdlet configures the computer to receive PowerShell remote commands that are sent by using the WS-Management technology.
Read more >Using PSScriptAnalyzer to check PowerShell version ...
The syntax check rule simply requires a list of PowerShell versions you want to target, and will tell you if a syntax used...
Read more >Import-Module (Microsoft.PowerShell.Core)
By default, Import-Module imports all members that the module exports, but you can use the Alias, Function, Cmdlet, and Variable parameters to restrict...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll mark it for discussion in our next issue triage
@bergmeister didn’t see that. Thanks!