Get-ModuleCommand should (optionally?) look at Value in ExportedCommands
cdhunt opened this issue · comments
Is your feature request related to a problem? Please describe.
I have a module that uses a DefaultCommandPrefix to disambiguate from built-in cmdlet names. Get-ModuleCommand operates on the key which is the command name before applying the prefix. This causes it to query info on the built-in command versus my command.
Example:
DefaultCommandPrefix = 'my'
New-Service
vs New-myService
I want info on New-myService
Describe the solution you'd like
If Key -ne Value
, use Value
in Get-ModuleCommand.ps1#L53
Describe alternatives you've considered
I don't see anywhere that DefaultCommandPrefix
is exposed to the runtime so you can programmatically check.
I believe you could also always just use Value instead of Key.
Additional context
Get-Module myModule| Select-Object -ExpandProperty ExportedCommands
Key Value
--- -----
Get-Client Get-myClient
Get-Config Get-myConfig
Get-CurrentContext Get-myCurrentContext
Get-Namespace Get-myNamespace
Get-Service Get-myService
New-Namespace New-myNamespace
New-Service New-myService
New-ServicePort New-myServicePort
New-ServiceSpec New-myServiceSpec
Remove-Namespace Remove-myNamespace
Remove-Service Remove-myService
Set-Namespace Set-myNamespace
Set-Service Set-myService
Get-ModuleCommand
ModuleName: myModule
Name Alias Synopsis
---- ----- --------
Get-Service gsv Gets the services on the computer.
New-Service Creates a new Windows service.
Remove-Service Removes a Windows service.
Set-Service Starts, stops, and suspends a service, and changes its properties.
After poking around ExportedCommands
for a few minutes I can't track down what is generating the name with prefix. The prefix or prefixed name doesn't seem to be in CmdletInfo
. Pesky FormatData.
Yeah, I'm running in 7.
This looks like a PowerShell 7 bug with Get-Module
. Investigating.
Microsoft agrees that this is a bug in PowerShell 7. The workaround for us appears to be first import the module then run Get-ModuleCommand
.
This is still a bug in PowerShell 7.2.
Is this still an issue for you? It has been a while since this was opened.
I'm not currently using this module. I can't say.
I think I'm going to close the issue then. We can always re-open it or start anew.