Try using PnP from a remote machine; the binaries between PnP and CSOM provided with SharePoint Server may be conflicting.
rror using PowerShell PnP with SharePoint 2016 ON PREM -- Unable to load one or more of the requested types
NOTE: All of the below is being executed on a SP 2016 WFE Server in an on-prem farm
I am trying to just run a quick test where I set up a basic SP 2016 Team Site that I want to use as a “template”. I moved around a couple of things on the site and added a layout table and a couple OOTB web parts on the home page. Then I used PnP to create a connection and generate a template file:
Get-PnPProvisioningTemplate -Out "PnP-Provisioning-File.xml" -Schema V201508
This did successfully generate a template file. Then I created another (default) TeamSite using Central Admin and I now want to apply the previously generated template to that site. So I create a connection and then call
Apply-PnPProvisioningTemplate -Path "TemplateFIle.xml" -ClearNavigation -IgnoreDuplicateDataRowErrors
When that call executes it throws the below error …
PS C:\WINDOWS\system32> C:\Users\sp-diab-install\Desktop\PnPProvisioner.ps1
Hit Line breakpoint on 'C:\Users\sp-diab-install\Desktop\PnPProvisioner.ps1:12'
[DBG]: PS C:\WINDOWS\system32>>
Apply-PnPProvisioningTemplate : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At C:\Users\sp-diab-install\Desktop\PnPProvisioner.ps1:12 char:5
- Apply-PnPProvisioningTemplate -Path "C:\temp\PnP-Provisioning-Fil ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ReflectionTypeLoadException
- FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate
which based on all the posts I am finding indicates that some DLL or other dependency is “missing”. Everything says to look at the LoaderExeptions property, which I (think) I finally figured out how to get, and it shows this:
Method not found: 'System.Threading.Tasks.Task`1<System.Net.Http.HttpResponseMessage> Microsoft.Graph.IHttpProvider.SendAsync(System.Net.Http.HttpRequestMessage,
System.Net.Http.HttpCompletionOption, System.Threading.CancellationToken)'.
Based on this, I assumed that I was missing the Graph module (although NOTHING anywhere around PnP mentions that this is needed …). Anyway, I installed it and then added a load statement to my script (which executes fine)
But the error persists … any thoughts on how I can get past this issue? Spent the last two days trying to figure this out --- everyone talks about it online but no one provides any good instructions on how to get it resolved.
Any ideas appreciated.
Thanks
Microsoft 365 and Office | SharePoint Server | Development
Windows for business | Windows Server | User experience | PowerShell
1 additional answer
Sort by: Most helpful
-
Rene Wagner 161 Reputation points
2021-01-21T00:03:00.843+00:00 The answer was provided by @trevorseward above along with this post: https://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=802