SharePoint Online Troubleshooting: Import-Module - Could not Load Assembly (Version Issue)

Summary

Just started the day with an Operational issue. SharePoint Online reports didn’t work as expected. The script which we scheduled didn’t send site collection reports to content managers! Let’s see the issue and fix it in this TechNet Wiki article. If you are new to SharePoint Online Management Shell, please refer to the below links and make use of it!

References

Issue

Could not load type 'Microsoft.Online.SharePoint.TenantAdministration.CompanyWideSharingLinksPolicy' from assembly 'Microsoft.Online.SharePoint.Client.Tenant, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

Stack Trace

Solution

We have a custom module build based on the client requirements and all the scripts are scheduled in the Windows Server 2012 box failed. In short, the issue is due to DLL Version mismatch. We have installed the SharePoint Online Management Shell which stores the required components in “C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell” in the location we can see a “Microsoft.Online.SharePoint.Client.Tenant.DLL” and found two different versions of file!

Absolutely Incorrect! To come out of this issue reinstall the SharePoint Online Management Shell. We tried repair but no luck.

Conclusion

Just reinstalled and checked the SharePoint Online Management Module to fix it.

Tested all codes built using CSOM | C# and PowerShell and confirmed all works as expected. Shared all the versions of SDK in the below links: