You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get-Command doesn't properly recognize System.Management.Automation.CommandInfo (its own output type) as pipeline input #11017
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues
#10851 reported that feeding Get-Command output to itself via the pipeline - useful if you want to force loading of all modules in the context of reflection, for instance - doesn't work as expected.
So what's happening is that the foo function doesn't have a Noun or Verb (they are empty strings), but it does have a Noun and Verb property, so when it's piped to gcm it binds to -Noun and -Verb, since they are empty string, gcm does a wildcard search thus returning everything. A simpler repro:
functionfoo{}; gcm foo | gcm
Adding a new parameterset to accept CommandInfo won't help as the default parameter set is Noun/Verb which will match any CommandInfo object.
A possible fix would be if Noun and Verb are both empty, inspect the pipeline object further and use whatever is available to match: Name and CommandType
Given there is currently no pipeline parameter accepting this object as input in its complete form, would that information be available to Get-Command?
Rain Sallow (/u/ta11ow) (@vexx32) excellent point, it wouldn't as only Noun and Verb would be there. Hmmm, I guess the only way to fix this I can think of is a breaking change so that CommandInfo parameterset is default.
Reacted by Rain Sallow (/u/ta11ow) and PRASOON KARUNAN V
It doesn't necessarily bind first, but, as I just realized, it does if you combine it with a parameter not supported in a potential new CommandInfo-typed parameter set.
So the choices are:
(a) change the default parameter set
(b) make the new parameter set support all other parameters (except -Name), even though some combinations don't make sense (such as -UseFuzzyMatching).
I'm unclear on the ramifications of (a)
(b) could be addressed by either warning about inapplicable arguments or throwing an error (there's already one instance of that in the existing code).
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues
Activity
SteveL-MSFT commentedon Nov 8, 2019
So what's happening is that the
foofunction doesn't have a Noun or Verb (they are empty strings), but it does have a Noun and Verb property, so when it's piped togcmit binds to-Nounand-Verb, since they are empty string,gcmdoes a wildcard search thus returning everything. A simpler repro:Adding a new parameterset to accept CommandInfo won't help as the default parameter set is Noun/Verb which will match any CommandInfo object.
A possible fix would be if Noun and Verb are both empty, inspect the pipeline object further and use whatever is available to match: Name and CommandType
vexx32 commentedon Nov 8, 2019
Given there is currently no pipeline parameter accepting this object as input in its complete form, would that information be available to Get-Command?
SteveL-MSFT commentedon Nov 8, 2019
Rain Sallow (/u/ta11ow) (@vexx32) excellent point, it wouldn't as only Noun and Verb would be there. Hmmm, I guess the only way to fix this I can think of is a breaking change so that CommandInfo parameterset is default.
mklement0 commentedon Nov 8, 2019
Steve Lee (@SteveL-MSFT): It's fine to leave the default parameter set as-is - a specifically
CommandInfo-typed parameter would still bind correctly.SteveL-MSFT commentedon Nov 8, 2019
Michael Klement (@mklement0) it would bind correctly if the default parameter set doesn't bind first which it will
mklement0 commentedon Nov 8, 2019
Steve Lee (@SteveL-MSFT)
It doesn't necessarily bind first, but, as I just realized, it does if you combine it with a parameter not supported in a potential new
CommandInfo-typed parameter set.So the choices are:
(a) change the default parameter set
(b) make the new parameter set support all other parameters (except
-Name), even though some combinations don't make sense (such as-UseFuzzyMatching).I'm unclear on the ramifications of (a)
(b) could be addressed by either warning about inapplicable arguments or throwing an error (there's already one instance of that in the existing code).
SteveL-MSFT commentedon Nov 8, 2019
Changing the default parameter set makes the most sense to me, but also unclear how many will be impacted.
iSazonov commentedon Nov 9, 2019
We could add optional parameter -Name in the default parameter set.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.