pnpframework
pnpframework copied to clipboard
Invoke-PnPSiteTemplate fails with "The property or field 'HeaderLayout' has not been initialized"
Hello,
when I export a site template via the "Get-PnPSiteTemplate -IncludeAllClientSidePages -PersistBrandingFiles -PersistPublishingFiles" command and then try to invoke it on another site the issue occurs.
Invoke-PnPSiteTemplate : The property or field 'HeaderLayout' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. At line:1 char:1 Invoke-PnPSiteTemplate -Path C:\Temp\spo\PNP2\PnpTemplate.xml -ClearN ... CategoryInfo : WriteError: (:) [Invoke-PnPSiteTemplate], PropertyOrFieldNotInitializedException FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.InvokeSiteTemplate
I tried the nighly builds to export a "extended" header. So the header section in the export looks like this:
<pnp:Header Layout="Extended" MenuStyle="MegaMenu" BackgroundEmphasis="Strong" ShowSiteTitle="false" ShowSiteNavigation="false" />
I was able to reproduce it in 1.8.62 abd 1.8.61. I am trying with SharePoint Online modern sites
Small update, when I change the header style to "Compact" it works.
This works:
<pnp:Header Layout="Compact" MenuStyle="MegaMenu" BackgroundEmphasis="Strong" ShowSiteTitle="false" ShowSiteNavigation="false" />
This doesn't
<pnp:Header Layout="Extended" MenuStyle="MegaMenu" BackgroundEmphasis="Strong" ShowSiteTitle="false" ShowSiteNavigation="false" />
i have the same problem. In my case it doesn't work with Minimal.
<pnp:Header Layout="Minimal" MenuStyle="MegaMenu" ShowSiteTitle="false" ShowSiteNavigation="false" />
I was looking also at this issue on PnP.Framework code and found a pull request to fix this
Pull request: https://github.com/pnp/pnpframework/pull/562
The pull request will fix the missing types "Minimal" and "Extended", that's why is working for some options "Standard" and "Compact"
About the "The property or field 'HeaderLayout' has not been initialized" I commented on the pull request about this.