-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Steps to reproduce
Running the PSScriptAnalyzer test suite with PowerShell 7-preview1 has exposed a feature that does not seem to be implemented in current and old versions of PowerShell but starting with PowerShell7-preview1, the cmdlet throws an error
function global:Get-SimpleFunction { }
Get-Command global:Get-SimpleFunc*Expected behavior
In PowerShell 6.2.1 (and 5.1), Get-Command does not return anything (which I think is a bug or unfinished feature) but at least no error should be thrown. Ideally the cmdlet should also be returned.
Actual behavior
Starting with PowerShell7-preview1, the cmdlet throws an error, which definitely is a regression and will affect users of PSScriptAnalyzers (because PSSA issues Get-Command calls under the hood for some of its analysis of the loaded user's code)
Get-Command : Cannot find drive. A drive with the name 'global' does not exist.
At line:1 char:42
+ ... ion global:Get-SimpleFunction { }; Get-Command global:Get-SimpleFunc*
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (global:String) [Get-Command], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetCommandCommand
The problem is not so much that no object is being returned but rather that now an error is thrown. We need to review if this is by design or not.
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.1
PSEdition Core
GitCommitId 7.0.0-preview.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0