Powershell: Get-Command shows edition-incompatible commands

Created on 8 Nov 2018  Â·  6Comments  Â·  Source: PowerShell/PowerShell

Steps to reproduce

Get-Command -Type Cmdlet | ? Name -match New-PSWorkflowExecutionOption

Expected behavior

# No output

Actual behavior


CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          New-PSWorkflowExecutionOption                      2.0.0.0    PSWorkflow

Environment data

> $PSVersionTable

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

@adityapatwardhan may need to update the PSVersionTable there.

Area-Cmdlets-Core Issue-Bug Resolution-By Design

All 6 comments

Customers are hitting this. Repro with PS7 Preview.3:

Get-EventL<tab>

Expected nothing to match

Actual completes Get-EventLog which is in WinPS Mgmt module. Of course running the command returns a "command not found" error.

I'm also running 7 preview 3 and can't repro this. Windows PowerShell resolves and executes the command, but I get no tab completion for it in PS 7 or 6. That's the reason this issue is still unresolved -- we haven't seen a clear repro of it. If you're able to get this tab completion to happen with a from-source build, we can debug it and find out what the issue is. But I suspect it has to be on your machine and may be a question of system state (my chief suspicion is that this is a cache issue).

With @SteveL-MSFT repo above I only get the tabcompletion result when WindowsPSModulePath has been imported into the session in 7-p3

Otherwise on a new session it doesn't tab complete

Running @rjmholt original command returns nothing in either state for me

Ah - with the Windows PS module path at the end of the PSModulePath? That might mean the problem lies in being able to discover the command but not load the module because the 6.1 version is already loaded

@rjmholt
It loads the module (Microsoft.PowerShell.Management 3.1.0.0) behind the scenes:

PS C:\Users\aleksandar> gmo

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   6.1.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-It…
Script     2.0.0      beta4      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …

PS C:\Users\aleksandar> get-eventlog
get-eventlog : The term 'get-eventlog' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ get-eventlog
+ ~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (get-eventlog:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Suggestion [4,General]: The most similar commands are: Get-EventLog, New-EventLog, Get-Event.
PS C:\Users\aleksandar> gmo

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   6.1.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest   3.1.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest   6.1.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script     2.0.0      beta4      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …

Also, this line is misleading and unwanted for the missing commands:

Suggestion [4,General]: The most similar commands are: Get-EventLog, New-EventLog, Get-Event.

The WinPS compat feature in PS7 resolves this

Was this page helpful?
0 / 5 - 0 ratings