Mar 03 2019
02:56 PM
- last edited on
Feb 01 2023
02:02 PM
by
TechCommunityAP
Mar 03 2019
02:56 PM
- last edited on
Feb 01 2023
02:02 PM
by
TechCommunityAP
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?
Mar 03 2019 10:59 PM
Sep 24 2019 01:30 AM
Dec 24 2019 04:46 AM
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!
Jan 13 2020 02:26 AM - edited Jan 13 2020 02:27 AM
Thx @Glenn Goffin , this one worked for me !
Feb 17 2020 12:46 PM
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?
Mar 31 2020 09:32 AM
Apr 03 2020 08:13 AM
@Glenn Goffin Thanks for your help! It worked for me.
What are those assemblies for in C:\Windows\Microsoft.NET\assembly\GAC_MSIL ?
Apr 22 2020 09:21 AM
@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.
May 12 2020 05:13 AM
would be also very interesting for me whether "clearing" the GAC destroys SharePoint Server installation.
Aug 13 2020 03:25 PM
@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.
Sep 29 2020 03:48 AM
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
Oct 06 2020 12:59 PM
Thank you so much for your post. It has just worked for me after a lot of getting annoyed at powershell!
@Glenn Goffin
Nov 05 2020 11:32 AM
@Alexey Sadomov these steps worked for me. Thanks!
Dec 02 2020 06:43 AM
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
Dec 28 2020 05:32 PM
Saved my life here.
Thanks for this great help !!!!!
Feb 10 2021 09:04 PM
@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.
Apr 09 2021 03:51 AM
Jul 23 2021 09:46 AM
@Glenn Goffin you help me too with this steps
Thanks!!!