Connect-SPOService error:Could not load type 'Microsoft.SharePoint.Client.SharePointOnlineCredentials

Viewed 2077

I am trying to connect to SharePoint with Powershell Connect-SPOService But I get the error:

| Could not load type 'Microsoft.SharePoint.Client.SharePointOnlineCredentials' from assembly
     | 'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral,
     | PublicKeyToken=71e9bce111e9429c'.

I reinstalled Microsoft.Online.SharePoint.PowerShell and import it. But still. I also have PnP.PowerShell installed. can that be the issue?

1 Answers

This is due to DLL Version mismatch. To resolve the issue, follow these steps:

  1. Uninstall SharePoint Online Management Shell and SharePoint Online Client SDK if installed.
  2. Delete SharePoint Online Client Assemblies from: C:\Windows\Microsoft.NET\assembly\GAC_MSIL, Remove all Folders starting with name: Microsoft.SharePoint*
  3. Uninstall the module with Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell and reinstall the module Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Related