Getting 'Could not load file or assembly 'Microsoft.Identity.Client, Version=4.21.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Could not find or | load a specific file. (0x80131621)' on Connect-PnPOnline
I am trying to run a script in Powershell 7 using PnP.PowerShell version 1.5.0 and I am getting error:
Could not load file or assembly 'Microsoft.Identity.Client, Version=4.21.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Could not find or
| load a specific file. (0x80131621)
My connect statement is as follows:
Connect-PnPOnline -ClientId $env:PnPClientId -Url $URL -Tenant ($env:Tenant + ".onmicrosoft.com") -Thumbprint $env:PnPThumbprint
This seems to be an issue with PowerShell 7 as Windows PowerShell still seems to be working on this same PC using PnP.PowerShell.
Anyone have suggestions on what I might need to change? I have users running scripts in Windows PowerShell so hoping for a uniform statement that works in both PowerShell versions.
3 answers
Sort by: Newest
-
-
Kanta Prasad 26 Reputation points
2021-10-27T08:22:53.983+00:00 I removed Powershell 7 and it started working fine with PS 5.1.
-
Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,891 Reputation points Microsoft Vendor
2021-05-14T06:51:43.653+00:00 Hi,
Does updating to the latest version solve the problem? The current version is 1.5.42-nightly.
https://www.powershellgallery.com/packages/PnP.PowerShellIf the problem is not solved you can report it over here
https://github.com/pnp/powershell/issuesAs the module works with Windows PowerShell, you may also try loading the PnP.Powershell module using the Windows PowerShell Compatibility feature.
Import-Module -Name PnP.Powershell -UseWindowsPowerShell
Best Regards,
Ian Xue============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.