[X] Bug
[ ] Enhancement
[X] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013
Simply tried to apply a .pnp template to a recently created (with the New-PnPTenantSite cmdlet) SPO site collection.
Got the following error message:

After enabling debugging only the following log entries were created:
PowerShell_ISE.exe Information: 0 : 2017-01-24 11:54:33.2565 [OfficeDevPnP.Core] [0] [Information] File CEUsite.pnp retrieved from folder 0ms
PowerShell_ISE.exe Information: 0 : 2017-01-24 11:54:33.2565 [OfficeDevPnP.Core] [0] [Information] File CEUsite.pnp retrieved from folder 0ms
PowerShell_ISE.exe Information: 0 : 2017-01-24 11:54:33.2965 [OfficeDevPnP.Core] [0] [Information] File CEUsite.xml retrieved from folder 0ms
I can anytime reproduce it with Apply-PnPProvisioningTemplate.
Older version of my .pnp template file works well on the same site collection where the attached .pnp fails. Same fail happen with the .xml version.
CEUsite.zip
CEUsitexml.zip
My PnP version: SharePointPnPPowerShellOnline 2.11.1701.1
Thanks,
Zoltan
I get the same error
Environment is SP2013 On-premise Server (at version: Jan 2017 CU 15.0.4893.1000).
Expected behavior
Should apply the PnPProvisioningTemplate to connected Site
Actual behavior
PS C:\temp> Apply-PnPProvisioningTemplate -InputInstance $template
Apply-PnPProvisioningTemplate : Object reference not set to an instance of an object.
At line:1 char:1
Steps to reproduce behavior
Connect-PnPOnline -Url $sourceSiteUrl
$template = Get-PnPProvisioningTemplate -OutputInstance -IncludeSearchConfiguration -IncludeSiteGroups -PersistPublishingFiles -SkipVersionCheck -Force
New-PnPTenantSite -Url $newSiteUrl -Title $newSiteTitle -Template $newSiteTemplate -Owner $newSiteOwner -TimeZone $TimezoneId
Connect-PnPOnline -Url $newSiteUrl
Apply-PnPProvisioningTemplate -InputInstance $template
Using:
PnP PowerShell for SharePoint 2013 (on-premise)
What is the version of the Cmdlet module you are running?
Script 2.11.1701.1 SharePointPnPPowerShell2013
How did you install the PnP-PowerShell Cmdlets?
MSI Installed downloaded from GitHub
Installed through the PowerShell Gallery with Install-Module
I have the same problem with the latest version of SharePoint Online package. What could i do to fix this error?
Question: are you all using a team site template (STS) with publishing features enabled?
Yes, I do.
No, i don't is that recommended?
@jbranders That's not a recommended approach, so if you're not using then good. It however is something that folks have been doing a lot in the past
@jansenbe : So, the publishing features must be disabled before you get the template? That's maybe why i have all those errors.
Have this problem as well, latest PnP (installed via install-module) and SharePoint Online. No publishing features activated, Team Site as basis (very clean, just added an announcement list and changed the first page).
(Get-Module -Name SharePointPnPPowerShellOnline).Version
Major Minor Build Revision
2 11 1701 1
@peteke Indeed same as what i have, it's really strage. What could it be?
Downloaded the source to debug.
Error occurs on line 1534 in XMLPnPSchemaV201605Formatter.cs (https://github.com/SharePoint/PnP-Sites-Core/blob/9599cf2d801dbecf48112f6f693d1cc979815bb9/Core/OfficeDevPnP.Core/Framework/Provisioning/Providers/Xml/XMLPnPSchemaV201605Formatter.cs#L1546)
Code assumes that source.Navigation.GlobalNavigation.StructuralNavigation.NavigationNode is not null, but in my case it is. Might be because my site is newly created and have no structural navigation nodes?
result.Navigation.GlobalNavigation.StructuralNavigation.NavigationNodes.AddRange(
from n in source.Navigation.GlobalNavigation.StructuralNavigation.NavigationNode
select n.FromSchemaNavigationNodeToModelNavigationNodeV201605()
);
It could be a detail in the template xml. Try changing
<pnp:StructuralNavigation RemoveExistingNodes="false">
to
<pnp:StructuralNavigation RemoveExistingNodes="true">
If that works in your scenario @jbranders ...
I get the same error even after @peteke s proposed change in xml file.
Using SharePoint 2016 on prem.
PowerShell module version: 2.12.1702 (Used to get template)
.Net version: 2.12.1702.0 (Used to apply template)
We managed to internally reproduce, so marking this one as a bug.
Any news about it? I got the bug today.. (february 2018)
Hi,
I have also been able to reproduce this error. When using the Apply-PnPProvisioningTemplate cmdlet by giving the template as InputInstance it seems to crash if the template contains any resources to be uploaded to the site. I think the problem is that the FileConnector is lost.
Connecting to SharepointOnline using the latest pull as of today (10/15/2018).
I seem to only be able to replicate this bug when attempting to apply a template from memory using "-InputInstance"
For example:
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-a/site-template" 鈥揅redentials $UserCredential
$template = Get-PnPProvisioningTemplate -OutputInstance
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-b" 鈥揅redentials $UserCredential
New-PnPWeb -Title "$client" -Url "$clienturl" -Description "Internal Sharepoint Site for $client" -Template STS#3
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-b/$clienturl" 鈥揅redentials $UserCredential
Apply-PnPProvisioningTemplate -InputInstance $template -ProvisionFieldsToSubWebs
This yields the aforementioned error, but only after seemingly almost finishing loading the template.
However if I simply save the template out to a path locally on my machine, things work dandy.
Example:
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-a/site-template" 鈥揅redentials $UserCredential
Get-PnPProvisioningTemplate -Out "C:\Path\to\file.xml"
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-b" 鈥揅redentials $UserCredential
New-PnPWeb -Title "$client" -Url "$clienturl" -Description "Internal Sharepoint Site for $client" -Template STS#3
Connect-PnPOnline 鈥揢rl "https://contoso.sharepoint.com/sites-b/$clienturl" 鈥揅redentials $UserCredential
Apply-PnPProvisioningTemplate -Path "C:\Path\to\file.xml" -ProvisionFieldsToSubWebs
The above works for me, but I'd love to be able to utilize loading everything into memory.
@LC-cchristiansen the error you are getting is because the engine is not able to resolve the folder in which the files you refer to in the in-memory instance reside. When applying a template as a file, we assume the current folder, if not overridden, to be the root for any file references. In the case of an in-memory instance we cannot make this assumption. The solution to what you describe is to specify the -ResourceFolder parameter (besides -InputInstance) and point it to the root of the folder where the files reside (most likely there are some
@erwinvanhunen Thanks for quick reply! I'll take a look at that.