Open mark3grahams opened 1 year ago
@mark3grahams , thanks for reporting. Normally, this random "Method not found" error is due to unexpected assembly was imported into PowerShell console due to other modules. When you hit the issue again, please execute below script and check where Microsoft.Identity.*
and Azure.Identity
were loaded from.
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location
Will do. It will likely be a few days or so.
FullName Location Azure.Identity, Version=1.6.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8 \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Azure.Identity.dll
Microsoft.Identity.Client, Version=4.29.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\MicrosoftTeams\4.7.0\net472\Microsoft.Identity.Client.dll
Microsoft.Identity.Client, Version=4.36.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\PnP.PowerShell\1.12.0\Framework\Microsoft.Identity.Client.dll
Microsoft.Identity.Client, Version=4.37.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae C:\Program Files\WindowsPowerShell\Modules\MSAL.PS\4.37.0.0\Microsoft.Identity.Client.4.37.0\net45\Microsoft.Identity.Client.dll
Microsoft.Identity.Client, Version=4.46.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.Identity.Client.dll
Microsoft.Identity.Client.Desktop, Version=4.37.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae C:\Program Files\WindowsPowerShell\Modules\MSAL.PS\4.37.0.0\Microsoft.Identity.Client.Desktop.4.37.0\net461\Microsoft.Identity.Client.Desktop.dll
Microsoft.Identity.Client.Extensions.Msal, Version=2.18.4.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\PnP.PowerShell\1.12.0\Framework\Microsoft.Identity.Client.Extensions.Msal.dll
Microsoft.Identity.Client.Extensions.Msal, Version=2.23.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.Identity.Client.Extensions.Msal.dll
Microsoft.IdentityModel.Abstractions, Version=6.22.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.IdentityModel.Abstractions.dll
Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.7.16602, Culture=neutral, PublicKeyToken=31bf3856ad364e35 \Documents\WindowsPowerShell\Modules\AzureADPreview\2.0.2.149\Microsoft.IdentityModel.Clients.ActiveDirectory.dll
@mark3grahams , please import-module az.accounts
at the beginning of your script.
Is this a bug or something I am doing wrong?
No. it is a limitation of .NET and PowerShell so far. If one assembly is loaded into .NET runtime, it may interfere others which are depending on the same assembly but different version.
Is this a bug or something I am doing wrong?
Hi @mark3grahams. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve
” to remove the “issue-addressed” label and continue the conversation.
/unresolve.
I've done that and it did not seem to help.
# Importing the required modules $Modules = @' ActiveDirectory Az.Accounts ImportExcel '@ -split "`n" | ForEach-Object { $.trim() } $Modules | ForEach-Object { Import-Module -Name $\ -Force -ErrorAction Stop }
FullName Location Azure.Identity, Version=1.6.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8 \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Azure.Identity.dll
Microsoft.Identity.Client, Version=4.36.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\PnP.PowerShell\1.12.0\Framework\Microsoft.Identity.Client.dll
Microsoft.Identity.Client, Version=4.46.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.Identity.Client.dll
Microsoft.Identity.Client.Extensions.Msal, Version=2.18.4.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\PnP.PowerShell\1.12.0\Framework\Microsoft.Identity.Client.Extensions.Msal.dll
Microsoft.Identity.Client.Extensions.Msal, Version=2.23.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.Identity.Client.Extensions.Msal.dll
Microsoft.IdentityModel.Abstractions, Version=6.22.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 \Documents\WindowsPowerShell\Modules\Az.Accounts\2.10.4\PreloadAssemblies\Microsoft.IdentityModel.Abstractions.dll
@mark3grahams , what's the result if you only import Az.Accounts and execute Connect-AzAccount
?
The error has been hit or miss, but I’ll give this a try a few times today and report back.
Import-Module Az.Accounts
connect-azAccount
That seemed fine as it logged on with my user and not the certificate.
Do you have any other suggestions?
/unresolve
This is not resolved.
Still not resolved.
This module seems to be incompatible with dbatools.
Correction: Importing Az.Accounts
before dbatools
(in $Profile
, perhaps) seems to work.
Description
Seemingly randomly, I receive the following error when I log on as a service principal using a certificate. Restarting the terminal in VSCode sometimes resolves it. Sometimes it does not.
Issue script & Debug output
Environment data
Module versions
Error output