-
Notifications
You must be signed in to change notification settings - Fork 488
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
ERROR: Could not load file or assembly 'Microsoft.Identity.Client' (ExchangeOnlineManagement + PS 7.2.6) #4178
Comments
Bump |
I ran into this as well yesterday and today I ran into it in a plain powershell terminal window as well. In my case you cannot run |
@robertcaretta does @Paxxi's findings explain your original issue? |
I don't recall testing this with Teams. To be honest, I run into all kinds of oddities with modules that still seem to require 5.1. |
Yeah, unfortunately PowerShell 5.1 is restricted to using the GAC (Global Assembly Cache) on Windows, which is an old-fashioned way of loading DLLs and causes loads of issues, since only one DLL of a name can be in the cache at a time. So modules can real easily have dependency collisions. PowerShell 7 uses an ALC (Assembly Load Context) that allows modules (such as PowerShell Editor Services, etc.) to isolate their dependencies from other modules. |
So I am getting this error as well, but I DO NOT have MicrosoftTeams module installed. Get-InstalledModule reports: I get the same exact error as the poster on this line of code: Connect-ExchangeOnline -UserPrincipalName [email protected] -Credential $cred OperationStopped: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.41.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Same exact code was functioning fine in Powershell 5.1. which also has earlier version of ExchangeOnline powershell module 1.0.1. So knowing I only have Powershell 7.2.6, ExchangeOnlineManagement 3.0.0, and PnP.PowerShell 1.11.0, what is the issue with this error? PS: I have to use Powershell 7. If I could stay on 5.1 I would. |
Yeah, unfortunately PnP.PowerShell also causes issues for PowerShell 5.1, #3510. |
This issue was closed automatically as author feedback was indicated as needed, but there has been no activity in over a week. Please feel free to reopen with any available information! |
Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead. |
I'm still having issues with this using VS Code and PS 7.3. Seems like when both ExchangeOnlineManagement and PnP powershell modules are loaded there is a conflict of some kind which prevents Connect-ExchangeOnline from working correctly. |
That sounds likely, the authors of those modules unfortunately need to implement proper |
Found it: #3510 The AssemblyLoadContext as implemented in PnP.PowerShell is only isolating Microsoft.ApplicationInsights, and PnP.PowerShell has a lot more dependencies (namely Microsoft.Identity.Client) that conflict and need to be isolated in the same manner. |
This issue has been marked as duplicate and has not had any activity in a day. It has been closed for housekeeping purposes. |
Paxxi's answer saves my day |
Prerequisites
Summary
When using this extension I get the error below. However if I run the same commands in a regular powershell 7.2 window (not VS Code) the code below runs fine.
ERROR:
OperationStopped: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.41.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx'.
PowerShell Version
Visual Studio Code Version
Extension Version
[email protected]
Steps to Reproduce
Could you please test out this combination of tools?
Then try running these commands:
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -InlineCredential
Connect-ExchangeOnline -CertificateThumbprint 'YOURTHUMB' -AppID 'YOURAPP' -Organization 'YOURORG'
ERROR:
OperationStopped: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.41.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx'.
Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered: