Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-Module -ListAvailable doesn't respect DefaultPrefix #15743

Open
5 tasks done
jdhitsolutions opened this issue Jul 8, 2021 · 1 comment
Open
5 tasks done

Get-Module -ListAvailable doesn't respect DefaultPrefix #15743

jdhitsolutions opened this issue Jul 8, 2021 · 1 comment
Labels
In-PR Indicates that a PR is out for the issue Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine-Module

Comments

@jdhitsolutions
Copy link
Collaborator

jdhitsolutions commented Jul 8, 2021

Prerequisites

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.

@jdhitsolutions jdhitsolutions added the Needs-Triage The issue is new and needs to be triaged by a work group. label Jul 8, 2021
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 9, 2021

I guess it is because Import-Module can re-set the prefix with Prefix parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR Indicates that a PR is out for the issue Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine-Module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants