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

Import-Module -prefix <prefix> does not work with "Connect-GraphCertificate" #23

Open
thorstenbutz opened this issue Aug 16, 2024 · 1 comment

Comments

@thorstenbutz
Copy link

Import-Module -Name 'MiniGraph' -prefix 'Fred'
Connect-FredGraphCertificate -ClientId $clientId -TenantId $tenantId -Certificate $cert

ERROR message:
Get-Command: The term 'Connect-FredFredGraphCertificate' is not recognized as a name of a cmdlet, function, script file, or
executable program.

When I use any kind of prefix, I cannot run "Connect-FredGraphCertificate", neither on WinPS 5.1 nor on PS 7.4.4. Tested on multiple PCs, check with a colleque (same result).
I had a quick look a the module file, but I could not find any obvious bug in the code. Maybe someone knows the root cause of this already.

Same code works fine without the prefix.

Screenshot attached.
Screenshot 2024-08-16 141308

@nyanhp
Copy link
Contributor

nyanhp commented Aug 26, 2024

Indeed @thorstenbutz
image
The problem starts here:

Command = Get-Command (Get-PSCallStack)[1].InvocationInfo.MyCommand

@FriedrichWeinmann, maybe the InvocationName should be used here unless you spot a possible issue? If I recall correctly, InvocationName returns the name with which the command was invoked, which would contain the correct alias. Short from poring over the PowerShell code, I cannot say why MyCommand becomes Connect-PrefixPrefixGraph* - note the double prefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants