I get command suggestions for commands that just failed, presumably because a compatibility check isn't done.
Looks related to https://github.com/PowerShell/PowerShell/issues/8207.
> Set-Clipboard
Set-Clipboard : The term 'Set-Clipboard' 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
+ Set-Clipboard
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-Clipboard:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Set-Clipboard : The term 'Set-Clipboard' 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
+ Set-Clipboard
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-Clipboard:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [4,General]: The most similar commands are: Set-Clipboard, Get-Clipboard.
Name Value
---- -----
PSVersion 6.2.0-preview.4
PSEdition Core
GitCommitId 6.2.0-preview.4
OS Microsoft Windows 10.0.18334
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@rjmholt This does not seem to be related to your linked issue because gcm set-clipboard does not return anything.
The real issue and solution is https://github.com/PowerShell/PowerShell/issues/4307#issuecomment-391121584 whereby .Net Core 2.x does not have those APIs, therefore the cmdlet is not available on Windows and users should use the ClipboardText module instead atm.
However, should we maybe reopen #4307 once .Net Core 3 is there that would add the ClipBoard APIs @SteveL-MSFT ?
@bergmeister that's a good point about gcm Set-Clipboard not finding anything.
Also @SteveL-MSFT, this now happens with the suggestions addition:
> Set-Clipboard
Set-Clipboard : The term 'Set-Clipboard' 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
+ Set-Clipboard
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-Clipboard:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [4,General]: The most similar commands are: Set-Clipboard, Get-Clipboard.
The suggestion relies on Get-Command so those cmdlets are being found. The question is whether we can/should do a compat check before showing it. I suppose we can enhance the suggestion script that calls Get-Command to get the module of the command and check CompatiblePSEditions to filter out commands we think are not compatible.
Why is Get-Command even able to find incompatible cmdlets in the first place?
Ah, so the suggestion is coming from https://github.com/PowerShell/PowerShell/issues/8207.
Why is
Get-Commandeven able to find incompatible cmdlets in the first place?
Because they're right there next to all the compatible modules, but it hasn't been enhanced with the manifest-property reading thing that skips it if CompatiblePSEditions doesn't contain "Core".