pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Apply-PnPProvisioningTemplate does not provision the site Navigation #2621

Closed ddbardsley closed 4 years ago

ddbardsley commented 4 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

I am use the following PowerShell command to acquire the site information which contains the pnp:Navigation tags within the XML template:

Get-PnPProvisioningTemplate -IncludeAllClientSidePages -Out $siteTemplateFile

I then use the following, prior to invoked the Get-PnPProvisioningTemplate, so that we Disable NoScript (since scripting is necessary for Navigation) on the tenant site. This is to ensure that we can provision the navigation settings.

Set-PnPTenantSite -Url $siteCollection -NoScriptSite:$false

And then I run the following to provision the site using the XML site template acquired from the Get-PnPProvisioningTemplate

Apply-PnPProvisioningTemplate -Web $web -Path $templateFile -OverwriteSystemPropertyBagValues -ClearNavigation -IgnoreDuplicateDataRowErrors

Here is the pnp:Navigation settings from the template file

### Expected behavior The Navigation items are not provisioned to the site (note: the required site pages, used by the navigation tags within the XML template, are already provisioned on the site). ### Actual behavior Site Navigation is not provisioned. ### Steps to reproduce behavior Apply-PnPProvisioningTemplate -Web $web -Path $templateFile -OverwriteSystemPropertyBagValues -ClearNavigation -IgnoreDuplicateDataRowErrors ### Which version of the PnP-PowerShell Cmdlets are you using? - [ ] PnP PowerShell for SharePoint 2013 - [ ] PnP PowerShell for SharePoint 2016 - [ X] PnP PowerShell for SharePoint Online ### What is the version of the Cmdlet module you are running? (you can retrieve this by executing ```Get-Module -Name *pnppowershell* -ListAvailable```) SharePointPnPPowerShellOnline 3.20.2004.0 ### How did you install the PnP-PowerShell Cmdlets? - [ ] MSI Installed downloaded from GitHub - [ X] Installed through the PowerShell Gallery with Install-Module - [ ] Other means Install-Module SharePointPnPPowerShellOnline -Force
ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ddbardsley commented 4 years ago

Hello, would someone please respond to this issue. We are trying to provision publishing sites but the Navigation items do not provision to the new sites.

ddbardsley commented 4 years ago

I have discovered the root cause of the problem. The issue is that the templates acquired from the pages within the "Pages" library (not to be confused with the "SitePages" library) via the "Get-PnPProvisioningTemplate" PowerShell API contain property keys which cause the "Apply-PnPProvisioningTemplate" PowerShell API provisioning process to fail with the following error message:

Apply-PnPProvisioningTemplate : Input string was not in a correct format

Since the pages fail to provision then the Navigation also fails because the navigation relies on these pages being successfully provisioned.

The problematic pnp:File property keys are:

AccessPolicy BSN _ListSchemaVersion _Dirty _Parsable _StubFile _VirusStatus _VirusVendorID _CheckinComment

I remove these property keys from each of the pnp:Files properties within the template (via the Read-PnPProvisioningTemplate PowerShell API) and the provisioning process successfully completes without an error.

Please let me know why these property keys are problematic and please let me know if there is way to exclude these property keys when invoking the Get-PnPProvisioningTemplate for the site pages found within the "Pages" library.

erwinvanhunen commented 4 years ago

We fixed this with commit: https://github.com/pnp/PnP-Sites-Core/commit/81ae1a1cae02e007afe5d9f01b71cd8647f0af32

The fix will be available in the July 2020 release.