Today I tried to apply a PnP template to a publishing site and I was getting the following error.

publishingerror

Apply-PnPProvisioningTemplate : The object specified does not belong to a list.
At line:1 char:1
+ Apply-PnPProvisioningTemplate -Path $templateFile -Web $departmentWe …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

I found in my template file that removing the following section would resolve the problem.

< pnp:File Src="oslo.master" Folder="{masterpagecatalog}" Overwrite="true">
< pnp:Properties>
< pnp:Property Key="ContentTypeId" Value="{contenttypeid:Master Page}" />
< pnp:Property Key="DefaultCssFile" Value="osloapp.css" />
< pnp:Property Key="_ListSchemaVersion" Value="1" />
< pnp:Property Key="_Dirty" Value="0" />
< pnp:Property Key="_Parsable" Value="1" />
< /pnp:Properties>
< /pnp:File>
< pnp:File Src="seattle.master" Folder="{masterpagecatalog}" Overwrite="true">
< pnp:Properties>
< pnp:Property Key="ContentTypeId" Value="{contenttypeid:Master Page}" />
< pnp:Property Key="DefaultCssFile" Value="corev15app.css" />
< pnp:Property Key="_ListSchemaVersion" Value="1" />
< pnp:Property Key="_Dirty" Value="0" />
< pnp:Property Key="_Parsable" Value="1" />
< /pnp:Properties>
< /pnp:File>

So I tried adding -ExcludeHandlers Publishing to my Apply-PnPProvisioningTemplate command but that didn’t work.

My workaround

I was exporting the template form an existing site using:

Get-PnPProvisioningTemplate -Out $templateFile   -Web templates/departmenttemplate

I added the -ExcludeHandlers Publishing here

Get-PnPProvisioningTemplate -Out $templateFile   -Web templates/departmenttemplate -ExcludeHandlers Publishing

And now my master pages are excluded form the Files to be provisioned through the PnP provisioning template

More details

https://github.com/SharePoint/PnP-Sites-Core/issues/865


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading