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%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%3CLINGO-SUB%20id%3D%22lingo-sub-1587996%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-1587996%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F11537%22%20target%3D%22_blank%22%3E%40Kirk%20Munro%3C%2FA%3E%26nbsp%3Balthough%20I%20strongly%20agree%20with%20your%20cautious%20approach%20to%20this%2C%20I%20wanted%20to%20note%20that%20my%20various%20attempts%20to%20uninstall%20the%20SharePoint%20Online%20Components%20(e.g.%20initial%20uninstall%20%3D%20no%20luck.%26nbsp%3B%20re-install%20and%20uninstall%20using%20elevated%20command%20prompt%20%3D%20no%20luck)%20never%20did%20the%20trick.%26nbsp%3B%20Using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F142376%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3B's%20GAC%20%22nuclear%20option%22%20was%20what%20finally%20did%20the%20trick%20for%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20assume%20the%20SOC%20components%20came%20in%20from%20my%20Visual%20Studio%202019%20install%20since%20I%20don't%20know%20how%20else%20they%20got%20installed%2C%20btw.%26nbsp%3B%20But%20for%20now%2C%20adios%20SOC%2FCOSM%20dlls.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20Kirk%2C%20your%20warnings%20may%20be%20especially%20important%20for%20those%20(unlike%20me)%20who%20are%20doing%20ShPt%20dev%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERespectfully%2C%20D.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602780%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-1602780%22%20slang%3D%22en-US%22%3EThank%20you%20worked.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1723768%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-1723768%22%20slang%3D%22en-US%22%3E%3CP%3EManual%20removing%20CSOM%20assemblies%20from%20the%20GAC%20is%20not%20a%20good%20idea%20-%20especially%20if%20you%20have%20SP%20on-prem%20running%20on%20the%20same%20server.%20Problem%20is%20caused%20by%20several%20instances%20of%20SPO%20SDKs%20and%20may%20be%20solved%20this%20way%3A%3C%2FP%3E%0A%3CP%3E1.%20Open%20Control%20Panel%20-%26gt%3B%20UnInstall%20Programs%20-%26gt%3B%20Search%20for%20SharePoint%20related%20setups.%3CBR%20%2F%3E2.%20Locate%20SharePoint%20Client%20Components%20-%26gt%3B%20Uninstall.%3CBR%20%2F%3E3.%20Locate%20SharePoint%20Online%20Management%20Shell%20-%26gt%3B%20Uninstall.%3CBR%20%2F%3E4.%20Ensure%20that%20anyone%20of%20the%20above%20setup%20is%20installed%20more%20than%20one%20time.%20If%20so%2C%20remove%20all%20the%20instances.%3CBR%20%2F%3E5.%20Now%2C%20open%20the%20Powershell%20console%20in%20administrative%20mode%20(Run%20as%20administrator).%3CBR%20%2F%3E6.%20Uninstall%20SPO%20Powershell%20module%20(If%20already%20exists)%20by%20running%20this%20command%3A%20Uninstall-Module%20-Name%20Microsoft.Online.SharePoint.PowerShell%20-AllVersions%20-Force%3CBR%20%2F%3E7.%20Finally%2C%20install%20the%20latest%20SPO%20Powershell%20module%20by%20running%20this%20command%3A%20Install-Module%20Microsoft.Online.SharePoint.PowerShell%20-Force%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1750984%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-1750984%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20for%20your%20post.%20It%20has%20just%20worked%20for%20me%20after%20a%20lot%20of%20getting%20annoyed%20at%20powershell!%3CBR%20%2F%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%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1858556%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-1858556%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F150496%22%20target%3D%22_blank%22%3E%40Alexey%20Sadomov%3C%2FA%3E%26nbsp%3Bthese%20steps%20worked%20for%20me.%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1948810%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-1948810%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%3EHello%20everybody%2C%3CBR%20%2F%3EI%20had%20the%20same%20problem%20and%20was%20able%20to%20fix%20it%20with%20the%20manual%2C%20so%20my%20scripts%20all%20work%20fine%2C%20thanks%20for%20that.%3CBR%20%2F%3EBut%20when%20I%20execute%20the%20script%20as%20a%20scheduled%20task%20I%20get%20this%20message%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%26gt%3BTerminatingError(Import-Module)%3A%20%22Could%20not%20load%20type%20'Microsoft.SharePoint.Administration.DesignPackageType'%20from%20assembly%20'Microsoft.SharePoint.Client%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c'.%22%0AImport-Module%20%3A%20Could%20not%20load%20type%20'Microsoft.SharePoint.Administration.DesignPackageType'%20from%20assembly%20%0A'Microsoft.SharePoint.Client%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c'.%0AAt%20C%3A%5CUsers%5Cxxx%5CDesktop%5CSkripte%5CCreate-TECTeams.ps1%3A71%20char%3A1%0A%2B%20Import-Module%20-Name%20Microsoft.Online.SharePoint.PowerShell%0A%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%0A%2B%20CategoryInfo%20%3A%20NotSpecified%3A%20(%3A)%20%5BImport-Module%5D%2C%20TypeLoadException%0A%2B%20FullyQualifiedErrorId%20%3A%20System.TypeLoadException%2CMicrosoft.PowerShell.Commands.ImportModuleCommand%0APS%26gt%3BTerminatingError(Import-Module)%3A%20%22Could%20not%20load%20type%20'Microsoft.SharePoint.Administration.DesignPackageType'%20from%20assembly%20'Microsoft.SharePoint.Client%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c'.%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20what%20to%20do%2C%20if%20someone%20has%20an%20idea...%20I%20would%20be%20glad%20about%20every%20help.%3C%2FP%3E%3CP%3Ebest%20regards%3CBR%20%2F%3EKai%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2019394%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-2019394%22%20slang%3D%22en-US%22%3E%3CP%3ESaved%20my%20life%20here.%3CBR%20%2F%3EThanks%20for%20this%20great%20help%20!!!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2121276%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-2121276%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F264809%22%20target%3D%22_blank%22%3E%40Andy_Bond%3C%2FA%3E%26nbsp%3Band%20anyone%20else%20interested.%3C%2FP%3E%3CP%3EI%20have%20done%20several%20days%20searching%20for%20a%20solution%20and%20believe%20I%20have%20come%20across%20a%20few%20causes%20and%20solutions.%3C%2FP%3E%3CP%3EThe%20obvious%20one%20is%20multiple%20versions%20of%20the%20module%20installed.%20The%20obvious%20is%20to%20uninstall%20all%20versions%20and%20install%20the%20latest%20either%20using%20Install-Module%20or%20obtaining%20the%20MSI%20from%20Microsoft.%20Very%20annoying%20but%20it%20does%20ensure%20that%20you%20have%20a%20reasonably%20clean%20environment.%20Along%20with%20uninstalling%20all%20versions%20is%20to%20follow%20the%20instructions%20provided%20by%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F142376%22%20target%3D%22_blank%22%3E%40Glenn%20Goffin%3C%2FA%3E%26nbsp%3Bunless%2C%20of%20course%2C%20you%20are%20doing%20this%20on%20a%20SharePoint%20server.%20Do%20not%20delete%20those%20directories%20from%20your%20SharePoint%20server!%3C%2FP%3E%3CP%3EAnother%20interesting%20one%20surfaced%20where%20the%20error%20was%20being%20generated%20within%20the%20Exchange%20Management%20Shell%20(EMS)%20but%20didn't%20happen%20with%20the%20standard%20PowerShell%20window.%3CBR%20%2F%3EWe%20onboard%20hundreds%20of%20accounts%20a%20day%20and%20part%20of%20the%20onboarding%20includes%20OneDrive%20test%20and%20request.%20The%20EMS%2C%20it%20turned%20out%2C%20this%20was%20our%20issue.%20As%20a%20result%2C%20I%20ended%20up%20writing%20the%20following%20function%20to%20replicate%20the%20EMS%20in%20a%20normal%20PowerShell%20window.%20Please%20read%20through...%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Eif%20(!(%24exscripts%20-and%20%24ExPath))%20%7B%0A%20%24path%20%3D%20%22HKLM%3A%5CSoftware%5CMicrosoft%5CExchangeServer%22%0A%20%24keys%20%3D%20Get-ChildItem%20-Path%20%24path%20-Recurse%0A%0A%20ForEach(%24Key%20in%20%24Keys)%20%7B%0A%20%20ForEach%20(%24Value%20in%20(Get-ItemProperty%20-Path%20%24key.PSPath%20-Name%20%22MsiInstall*%22))%7B%0A%20%20%20if%20(%24Value.MsiInstallPath%20-match%20%22Exchange%22%20-and%20%24Value.MsiInstallPath%20-match%20%22bin%22)%20%7B%0A%20%20%20%20%24ExPath%20%3D%20%24Value.MsiInstallPath%0A%20%20%20%7D%0A%0A%20%20%7D%0A%20%7D%0A%20if%20(Test-Path%20%24ExPath)%20%7B%0A%20%20%24ExPath%20%3D%20%22%24ExPath%5CRemoteExchange.ps1%22%0A%20%20.%20%24ExPath%0A%20%7D%0A%20else%20%7B%0A%20%20Write-Host%20%22Exchange%20tools%20are%20not%20installed%20on%20this%20server%20or%20are%20installed%20in%20a%20different%20path%22%20-ForegroundColor%20Yellow%0A%20%20%22Check%20the%20tools%20are%20installed%20and%20update%20the%20path%20in%20%24(%24MyInvocation.MyCommand.Name)%20and%20search%20for%20'%24ExPath'%22%0A%20%20Exit-Script%0A%20%7D%0A%7D%0A%0A%24EXSession%20%3D%20Get-PSSession%20%7C%20Where-Object%20%7B%24_.ComputerName%20-match%20%22Partial_HostName%22%7D%20%23%23%20We%20have%20an%20exchange%20cluster%20with%20incremental%20naming%20convention%0A%0Aif%20(!(%24EXSession))%20%7B%0A%20%22Connecting%20to%20Exchange%22%0A%20Connect-ExchangeServer%20-Auto%20-AllowClobber%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EObviously%2C%20this%20will%20only%20work%20if%20you%20have%20the%20Exchange%20tools%20installed%20on%20the%20host%20running%20the%20script.%3C%2FP%3E%3CP%3EThe%20trick%20is%20to%20load%20the%20SharePoint%20Online%20modules%20first%20and%20then%20the%20EMS%20code%20above.%20So%20far%2C%20in%20the%20last%204%20hours%20and%20the%20script%20running%20every%205%20minutes%2C%20there%20has%20not%20been%20an%20error.%3C%2FP%3E%3CP%3ETo%20note%2C%20we%20are%20running%20a%20hybrid%20Exchange%20environment%20so%20I%20am%20not%20sure%20if%20the%20issue%20is%20present%20when%20the%20Exchange%20Online%20tools%20are%20loaded%20before%20SharePoint%20Online%20as%20I%20moved%20SharePoint%20to%20be%20the%20first%20module%20loaded.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2263623%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-2263623%22%20slang%3D%22en-US%22%3EThis%20worked%20for%20me.%20Thanks!%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2580646%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-2580646%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%20you%20help%20me%20too%20with%20this%20steps%3C%2FP%3E%3CP%3EThanks!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E
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?

19 Replies
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
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.


 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:

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? 

Thanks for your help! It worked for me.

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

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

@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.

@Allison Bates 

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

@Kirk Munro although I strongly agree with your cautious approach to this, I wanted to note that my various attempts to uninstall the SharePoint Online Components (e.g. initial uninstall = no luck.  re-install and uninstall using elevated command prompt = no luck) never did the trick.  Using @Glenn Goffin 's GAC "nuclear option" was what finally did the trick for me.

 

I assume the SOC components came in from my Visual Studio 2019 install since I don't know how else they got installed, btw.  But for now, adios SOC/COSM dlls.

 

So, Kirk, your warnings may be especially important for those (unlike me) who are doing ShPt dev work.

 

Respectfully, D.

Thank you worked.

Manual removing CSOM assemblies from the GAC is not a good idea - especially if you have SP on-prem running on the same server. Problem is caused by several instances of SPO SDKs and may be solved this way:

1. Open Control Panel -> UnInstall Programs -> Search for SharePoint related setups.
2. Locate SharePoint Client Components -> Uninstall.
3. Locate SharePoint Online Management Shell -> Uninstall.
4. Ensure that anyone of the above setup is installed more than one time. If so, remove all the instances.
5. Now, open the Powershell console in administrative mode (Run as administrator).
6. Uninstall SPO Powershell module (If already exists) by running this command: Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell -AllVersions -Force
7. Finally, install the latest SPO Powershell module by running this command: Install-Module Microsoft.Online.SharePoint.PowerShell -Force

Thank you so much for your post. It has just worked for me after a lot of getting annoyed at powershell!
@Glenn Goffin 

@Alexey Sadomov these steps worked for me. Thanks!

@Glenn Goffin 

Hello everybody,
I had the same problem and was able to fix it with the manual, so my scripts all work fine, thanks for that.
But when I execute the script as a scheduled task I get this message again.

 

PS>TerminatingError(Import-Module): "Could not load type 'Microsoft.SharePoint.Administration.DesignPackageType' from assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'."
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 C:\Users\xxx\Desktop\Skripte\Create-TECTeams.ps1:71 char:1
+ Import-Module -Name Microsoft.Online.SharePoint.PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], TypeLoadException
+ FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
PS>TerminatingError(Import-Module): "Could not load type 'Microsoft.SharePoint.Administration.DesignPackageType' from assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'."

 

I don't know what to do, if someone has an idea... I would be glad about every help.

best regards
Kai

Saved my life here.
Thanks for this great help !!!!!

 

@Andy_Bond and anyone else interested.

I have done several days searching for a solution and believe I have come across a few causes and solutions.

The obvious one is multiple versions of the module installed. The obvious is to uninstall all versions and install the latest either using Install-Module or obtaining the MSI from Microsoft. Very annoying but it does ensure that you have a reasonably clean environment. Along with uninstalling all versions is to follow the instructions provided by @Glenn Goffin unless, of course, you are doing this on a SharePoint server. Do not delete those directories from your SharePoint server!

Another interesting one surfaced where the error was being generated within the Exchange Management Shell (EMS) but didn't happen with the standard PowerShell window.
We onboard hundreds of accounts a day and part of the onboarding includes OneDrive test and request. The EMS, it turned out, this was our issue. As a result, I ended up writing the following function to replicate the EMS in a normal PowerShell window. Please read through...

if (!($exscripts -and $ExPath)) {
	$path = "HKLM:\Software\Microsoft\ExchangeServer"
	$keys = Get-ChildItem -Path $path -Recurse

	ForEach($Key in $Keys) {
		ForEach ($Value in (Get-ItemProperty -Path $key.PSPath -Name "MsiInstall*")){
			if ($Value.MsiInstallPath -match "Exchange" -and $Value.MsiInstallPath -match "bin") {
				$ExPath = $Value.MsiInstallPath
			}

		}
	}
	if (Test-Path $ExPath) {
		$ExPath = "$ExPath\RemoteExchange.ps1"
		. $ExPath
	}
	else {
		Write-Host "Exchange tools are not installed on this server or are installed in a different path" -ForegroundColor Yellow
		"Check the tools are installed and update the path in $($MyInvocation.MyCommand.Name) and search for '$ExPath'"
		Exit-Script
	}
}

$EXSession = Get-PSSession | Where-Object {$_.ComputerName -match "Partial_HostName"} ## We have an exchange cluster with incremental naming convention

if (!($EXSession)) {
	"Connecting to Exchange"
	Connect-ExchangeServer -Auto -AllowClobber
}

Obviously, this will only work if you have the Exchange tools installed on the host running the script.

The trick is to load the SharePoint Online modules first and then the EMS code above. So far, in the last 4 hours and the script running every 5 minutes, there has not been an error.

To note, we are running a hybrid Exchange environment so I am not sure if the issue is present when the Exchange Online tools are loaded before SharePoint Online as I moved SharePoint to be the first module loaded.

This worked for me. Thanks!

@Glenn Goffin  you help me too with this steps

Thanks!!!