Pnp-sites-core: Get-PnpProvisioningTemplate : Unable to load one or more of the requested types

Created on 11 Oct 2017  路  17Comments  路  Source: pnp/PnP-Sites-Core

$secpasswd = ConvertTo-SecureString "aaa" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("[email protected]", $secpasswd)
Connect-PnPOnline -Url https://aaa.sharepoint.com -Credentials $mycreds
Get-PnpProvisioningTemplate -Out test.xml


Get-PnpProvisioningTemplate : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At line:1 char:1

  • Get-PnpProvisioningTemplate -Out test.xml -Schema V ...
  • ~~~~~~~~~~~~~~~~~

    • CategoryInfo : WriteError: (:) [Get-PnPProvisioningTemplate], ReflectionTypeLoadException

    • FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.GetProvisioningTemplate

Most helpful comment

Update: we have identified the issue. It was due to Nuget removing an assembly instead of 'hiding' it (this is not normal behavior of nuget). The result was that while downloading the core library, where we reference that library, an updated version was downloaded, whereas the core library expects the older version. We will release a so called Intermediate Release version of both the PnP Core Library and PnP PowerShell later today (European time).

All 17 comments

I've got the same issue. I've tried different versions of PnP but it doesn't work. Now I have SharePointPnPPowerShellOnline 2.19.1710.0

script:
$credentials= Get-Credential
Connect-PnPOnline -Url $rootSite -Credentials $credentials
Get-PnPProvisioningTemplate -out template.xml

Error:
`Get-PnPProvisioningTemplate : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At line:1 char:1

  • Get-PnPProvisioningTemplate -out template.xml -Handlers Fields
  • ~~~~~~~~~~~~~~

    • CategoryInfo : WriteError: (:) [Get-PnPProvisioningTemplate], ReflectionTypeLoadException

    • FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.GetProvisioningTemplate`

EDIT:
I was able to fire this command w/out error by downgrading PnP to version 2.12.1702.0

Me and my colleagues experience the same issue with the same version as truespinmice also PS.
No problems using C# though.

Are we doing something very wrong?

I am having the same issue with the 2.19.1710.0 version of SharePointPnPPowerShell2016.

Step 1: Connect-PnPOnline "https://xxxxxxxxxxxxxxxx/sites/teamsite1"
Step 2: Get-PnPProvisioningTemplate -Out .\ExtractedSiteTemplate.xml
Exception on Step 2.

Version 2.19.1710.0 (October 2017 release)
MSI Installed downloaded from GitHub

I reverted back to 2.18.1709.1 (September 2017 Intermediate Release 1) and cmdlet runs without exceptions.

Same issue introduced in 2.19.1710.0. Confirmed with SharePointPnPPowerShell2016 and SharePointPnPPowerShell2013. Does not happen in previous versions. Also, I cannot compile latest Core and PowerShell code in VS2017 for ONPREM as of last night. First, I faced broken NuGet package references (obsolete versions that got removed from the NuGet Gallery). Then, there were namespace references that are not available with ONPREM compile flag.

How did you install the cmdlets? Did you use the MSI package or did you use package that comes from the PowerShell gallery (e.g. with install-module). For those with the issue, can you please reproduce the error and them immediately enter:

$error[0].Exception.Stacktrace

Please paste the output here.

Update: I was able to reproduce it and I'm working on a fix

Update: we have identified the issue. It was due to Nuget removing an assembly instead of 'hiding' it (this is not normal behavior of nuget). The result was that while downloading the core library, where we reference that library, an updated version was downloaded, whereas the core library expects the older version. We will release a so called Intermediate Release version of both the PnP Core Library and PnP PowerShell later today (European time).

I get this error too, with Apply-PnPProvisioningTemplate

Apply-PnPProvisioningTemplate : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more
information.
At X:\PowerShell\KYC\Provision-Subsites.ps1:189 char:5

  • Apply-PnPProvisioningTemplate -Path $templatePath -ClearNavigatio ...
  • ~~~~~~~~~~~~~

    • CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ReflectionTypeLoadException

    • FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

looking forward to the update. thanks

As I have the issue too, I'm looking forward to your solution! Thanks in advance :)

Hi @erwinvanhunen, I wrote about this issue here: https://github.com/SharePoint/PnP-PowerShell/issues/1129
Solution would be to change library version of Microsoft.IdentityModel.Clients.ActiveDirectory.dll back to 2.18.
Workaround is to manually preload Microsoft.IdentityModel.Clients.ActiveDirectory.dll v2.18 to Powershell using Add-Type before running cmdlets

@ivanvagunin - After the intermediate release for this month that @erwinvanhunen announced, I'd hope that it would not be necessary.

@erwinvanhunen - I have yet to see the Intermediate release for October. Do you have an ETA on this? I'd prefer not to revert back to 2.18.xxx but move forward. Thanks!

We are almost done, but we have some timezone/availability challenges. Hopefully we have the release out by tomorrow.

Thanks for the update Erwin

Get-PnPProvisioningTemplate : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

@erwinvanhunen would be really nice. Thanks a lot for your effort. My VSTS release agent failed until you fix this :)
Waiting for your new package, thanks in advance.

We just released a new version: 2.19.1710.1. It's available through the usual channels. I will close this issue, but do not hesitate to reopen it if you still experience issues.

I have created an azure function to provision sites. I am still getting the same issue at this line templateProvider.GetTemplate(baseTemplateName);. It works fine when I use 2016/05 schema and fails for 2017/05 schema. I have uninstalled the nuget package which I was using before and installed 2.19.1710.1. Still no luck. Also I have tried with latest nuget packages still getting same issue.

Was this page helpful?
0 / 5 - 0 ratings