MiniGraph icon indicating copy to clipboard operation
MiniGraph copied to clipboard

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

Open thorstenbutz opened this issue 1 year ago • 1 comments

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

thorstenbutz avatar Aug 16 '24 12:08 thorstenbutz

Indeed @thorstenbutz
image The problem starts here: https://github.com/FriedrichWeinmann/MiniGraph/blob/8d405ca2f81dc4052fe379e11226faa5db2f7b82/MiniGraph/internal/functions/Set-ReconnectInfo.ps1#L49 @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

nyanhp avatar Aug 26 '24 13:08 nyanhp