Can't import SharePoint online Powershell module

%3CLINGO-SUB%20id%3D%22lingo-sub-359630%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-359630%22%20slang%3D%22en-US%22%3ESome%20things%20you%20can%20try%3A%3CBR%20%2F%3E(1)%20Check%20If%20you%20already%20installed%20the%20module%20by%20means%20of%20the%20SharePoint%20Online%20Management%20Shell...if%20so%2C%20uninstall%20it%3CBR%20%2F%3E(2)%20Try%20to%20us%20the%20-force%20parameter%20in%20the%20Import-Module%20cmdlet%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-871594%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-871594%22%20slang%3D%22en-US%22%3EI%20had%20the%20exact%20same%20problem%2C%20mine%20was%20caused%20by%20Microsoft.SharePoint.Client.dll%20installed%20in%20the%20Global%20Assembly%20Cache.%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20resolve%20the%20issue%2C%3CBR%20%2F%3E(1)%20Navigate%20to%20C%3A%5CWindows%5CMicrosoft.NET%5Cassembly%5CGAC_MSIL%3CBR%20%2F%3E(2)%20Remove%20the%20Microsoft.SharePoint.*%20assemblies%3CBR%20%2F%3E(3)%20Uninstall%20the%20module%20with%20Uninstall-Module%20-Name%20Microsoft.Online.SharePoint.PowerShell%3CBR%20%2F%3E%3CBR%20%2F%3EAfter%20reinstalling%20the%20module%20from%20the%20PowerShell%20gallery%2C%20the%20module%20worked%20flawlessly.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1079551%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1079551%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3BI%20just%20found%20this%20thread%20because%20I%20was%20having%20the%20same%20problem%20-%20thank%20you%20for%20these%20instructions%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F212869%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%2C%20they%20did%20the%20trick%20for%20me!%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fsmile_40x40.gif%22%20alt%3D%22%3Asmile%3A%22%20title%3D%22%3Asmile%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1104436%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1104436%22%20slang%3D%22en-US%22%3E%3CP%3EThx%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F212869%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3B%2C%20this%20one%20worked%20for%20me%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-359581%22%20slang%3D%22en-US%22%3ECan't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-359581%22%20slang%3D%22en-US%22%3E%3CP%3Ewhen%20I%20use%3CBR%20%2F%3EImport-Module%20Microsoft.Online.SharePoint.PowerShell%3C%2FP%3E%3CP%3Eit%20says%3C%2FP%3E%3CP%3EPS%20C%3A%5CWindows%5Csystem32%26gt%3B%20Import-Module%20Microsoft.Online.SharePoint.PowerShell%3CBR%20%2F%3EImport-Module%20%3A%20Could%20not%20load%20type%20'Microsoft.SharePoint.Administration.DesignPackageType'%20from%20assembly%20'Microsoft.SharePoint.Client%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%3CBR%20%2F%3EPublicKeyToken%3D71e9bce111e9429c'.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20Import-Module%20Microsoft.Online.SharePoint.PowerShell%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20NotSpecified%3A%20(%3A)%20%5BImport-Module%5D%2C%20TypeLoadException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20System.TypeLoadException%2CMicrosoft.PowerShell.Commands.ImportModuleCommand%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20this%20binary%20module%20installed%3A%3C%2FP%3E%3CP%3EDirectory%3A%20C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EModuleType%20Version%20Name%20ExportedCommands%3CBR%20%2F%3E----------%20-------%20----%20----------------%3CBR%20%2F%3EBinary%2016.0.86...%20Microsoft.Online.SharePoint.Powe...%3CBR%20%2F%3EBinary%2016.0.80...%20Microsoft.Online.SharePoint.Powe...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20clues%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-359581%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1178159%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1178159%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F212869%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20very%20same%20error%2Fissue%20trying%20to%20load%20on%20a%20SharePoint%202019%20server.%26nbsp%3B%20I%20don't%20think%20it%20would%20be%20a%20good%20idea%20to%20delete%20all%20the%20Microsoft.SharePoint%20assemblies%20from%20this%20server.%26nbsp%3B%20%26nbsp%3BAny%20ideas%20if%20it%20will%20corrupt%20the%20SharePoint%20installation%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1268618%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1268618%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20help!%20It%20worked%20for%20me.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1279062%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1279062%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F212869%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3B%3CSPAN%3EThanks%20for%20your%20help!%20It%20worked%20for%20me.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20are%26nbsp%3B%3CSPAN%3Ethose%20assemblies%20for%20in%20C%3A%5CWindows%5CMicrosoft.NET%5Cassembly%5CGAC_MSIL%20%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1329433%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1329433%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F212869%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3BI%20don't%20think%20direct%20manipulation%20of%20dlls%20in%20the%20GAC%20is%20the%20right%20solution%20here.%20This%20issue%20is%20actually%20caused%20by%20a%20conflict%20with%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-ca%2Fdownload%2Fdetails.aspx%3Fid%3D42038%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESharePoint%20Online%20Components%20SDK%3C%2FA%3E.%20Recent%20versions%20of%20the%20Microsoft.Online.SharePoint.PowerShell%20module%20simply%20will%20not%20load%20as%20long%20as%20that%20is%20installed%20on%20a%20system.%20If%20you%20uninstall%20SharePoint%20Online%20Components%2C%20the%20module%20will%20load%20just%20fine.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1382363%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20import%20SharePoint%20online%20Powershell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1382363%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35784%22%20target%3D%22_blank%22%3E%40Allison%20Bates%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewould%20be%20also%20very%20interesting%20for%20me%20whether%20%22clearing%22%20the%20GAC%20destroys%20SharePoint%20Server%20installation.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

when I use
Import-Module Microsoft.Online.SharePoint.PowerShell

it says

PS C:\Windows\system32> Import-Module Microsoft.Online.SharePoint.PowerShell
Import-Module : Could not load type 'Microsoft.SharePoint.Administration.DesignPackageType' from assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c'.
At line:1 char:1
+ Import-Module Microsoft.Online.SharePoint.PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], TypeLoadException
+ FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

 

I have this binary module installed:

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 16.0.86... Microsoft.Online.SharePoint.Powe...
Binary 16.0.80... Microsoft.Online.SharePoint.Powe...

 

Any clues?

9 Replies
Highlighted
Some things you can try:
(1) Check If you already installed the module by means of the SharePoint Online Management Shell...if so, uninstall it
(2) Try to us the -force parameter in the Import-Module cmdlet
Highlighted
I had the exact same problem, mine was caused by Microsoft.SharePoint.Client.dll installed in the Global Assembly Cache.

To resolve the issue,
(1) Navigate to C:\Windows\Microsoft.NET\assembly\GAC_MSIL
(2) Remove the Microsoft.SharePoint.* assemblies
(3) Uninstall the module with Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell

After reinstalling the module from the PowerShell gallery, the module worked flawlessly.


Highlighted

 I just found this thread because I was having the same problem - thank you for these instructions @Glenn Goffin, they did the trick for me! :smile:

Highlighted

Thx @Glenn Goffin , this one worked for me !

@Glenn Goffin 

 

I have very same error/issue trying to load on a SharePoint 2019 server.  I don't think it would be a good idea to delete all the Microsoft.SharePoint assemblies from this server.   Any ideas if it will corrupt the SharePoint installation? 

Highlighted
Thanks for your help! It worked for me.
Highlighted

@Glenn Goffin Thanks for your help! It worked for me.

What are those assemblies for in C:\Windows\Microsoft.NET\assembly\GAC_MSIL ?

Highlighted

@Glenn Goffin I don't think direct manipulation of dlls in the GAC is the right solution here. This issue is actually caused by a conflict with SharePoint Online Components SDK. Recent versions of the Microsoft.Online.SharePoint.PowerShell module simply will not load as long as that is installed on a system. If you uninstall SharePoint Online Components, the module will load just fine.

Highlighted

@Allison Bates 

would be also very interesting for me whether "clearing" the GAC destroys SharePoint Server installation.