PowerShell / PowerShell/PowerShell
Get-Module -ListAvailable doesn't respect DefaultPrefix
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Use any module that has the DefaultCommandPrefix defined in the module manifest. I modified one of my modules to test with.
In Windows PowerShell, if I have a module that uses a defined prefix, this works as expected.
Expected behavior
PS C:\> $mod = Get-Module PSChristmas -ListAvailable
PS C:\> $mod.ExportedFunctions.keys
New-xElfName
Get-xPSChristmasPresent
New-xPSChristmasGreeting
New-xPSChristmas
Show-xPSChristmasMessage
Invoke-xJingle
Write-xFestive
The module is NOT loaded into my session. But not in PowerShell 7. PowerShell 7 fails to use the prefix.
Actual behavior
PS C:\> $mod = Get-Module PSChristmas -ListAvailable
PS C:\> $mod.ExportedFunctions.keys
New-ElfName
Get-PSChristmasPresent
New-PSChristmasGreeting
New-PSChristmas
Show-PSChristmasMessage
Invoke-Jingle
Write-Festive
If I import the module in PowerShell 7 and re-run the command then it works.
PS C:\> import-module pschristmas
PS C:\> $mod = Get-Module PSChristmas
PS C:\> $mod.ExportedFunctions.keys
Get-xPSChristmasPresent
Invoke-xJingle
New-xElfName
New-xPSChristmas
New-xPSChristmasGreeting
Show-xPSChristmasMessage
Write-xFestive
Environment data
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Also tested in 7.2.0-preview.4 with the same results.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with a module manifest that defines DefaultCommandPrefix, then compare Get-Module -ListAvailable with the behavior after Import-Module. Trace how exported functions are populated for the list-available path. Done means the listed exported function names include the manifest prefix before the module is imported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100