PowerShell / PowerShell/PowerShell
Get-Module -ListAvailable doesn't respect DefaultPrefix
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 55.5k
- Forks
- 8.5k
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 88
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Problem mit einem Modulmanifest, das DefaultCommandPrefix definiert, und vergleiche anschließend Get-Module -ListAvailable mit dem Verhalten nach Import-Module. Verfolge, wie exportierte Funktionen für den Pfad „list-available“ aufgefüllt werden. Als erledigt gilt die Aufgabe, wenn die Namen der aufgeführten exportierten Funktionen das Manifestpräfix enthalten, bevor das Modul importiert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100