Office 365 – Apply-PnPProvisioningTemplate with publishing pages

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 addeed 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

Advertisements


Categories:Office 365, Patterns And Practices, PnP, PowerShell, SharePoint, SharePoint Online

Tags: , , , ,

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: