Connect-PnPOnline suddenly at times getting "Could not load file or assembly 'Microsoft.Identity.Client, Version=4.50.0.0'" on script that has been working #3216
Replies: 3 comments 1 reply
-
I am also getting that second error |
Beta Was this translation helpful? Give feedback.
-
The issue with colliding assemblies should now be fixed! |
Beta Was this translation helpful? Give feedback.
-
I suddenly also experienced this error: So I ended up with this thread which in someway pointed me in finding a workaround, so I decided to share it with you as this is beyond all logic. Yes it results in my script not being chronologically anymore but at least I got my scripts working again. As a Bonus I previously also struggled with the colliding assemblies issues, but I got that one solved by writing this (also copied my comments around it :-) ):
This installs the module if missing, and remove the .dll file which is was causing the issue. Actually I expected issues with some parts of the module, but I didn't found any so far. Please take note that these simple fixes ar 100% workarounds, my suggestion is to regularly check if the issues got fixed and make your script work as it should be. Hopefully these simple fixes helps someone continuing their business without a hassling further :-) |
Beta Was this translation helpful? Give feedback.
-
I have a script that does the following command:
Connect-PnPOnline -Url $site -Tenant $tenant -ClientId $appClientID -CertificatePath $cert -CertificatePassword $(ConvertTo-Securestring -string $certPassword -AsPlainText -Force)
I run this script from the Task Scheduler. It is failing with:
I read somewhere else that this could be affected by the Azure Powershell object (which I did not have installed), so I installed them.
Now here is the odd thing:
In VS Code, $PSVersionTable says PSVersion = 7.3.4
From the Task Scheduler, PSVersion = 7.3.4
From the Powershell command window, PSVersion = 7.3.4
Get-InstalledModule -Name PnP.Powershell returns version 2.1.1
All are executing as me.
I then tried;
Install-Module -Name Microsoft.Identity.Client -RequiredVersion 4.50.0.0
Now on Connect-PnPOnline, I get:
Could not load type 'Microsoft.Extensions.DependencyInjection.ServiceCollection' from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0
Still works from the Powershell command window I open, but does not from VS Code or the Task Scheduler.
Why would it fail sometimes and work other times? What might be the cause?
Beta Was this translation helpful? Give feedback.
All reactions