1

So I have an issue while using the Get-PnPProvisioningTemplate comandlet... So I can go through and create lists and doclibs and pages all over a site, and create the provisioning template and that works fine.

But as soon a I change one element on the /Home.aspx page, I will get:

Get-PnPProvisioningTemplate : Object reference not set to an instance of an object.
At ...\SharePoint\PowerShellScripts\pnp provision\CreateTemplate.ps1:31 char:13
+             Get-PnPProvisioningTemplate -Out $ptoTemplate
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Get-PnPProvisioningTemplate], NullReferenceException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.Site.GetProvisioningTemplate

I know its' the [Client Side Page Contents] section because I run my script with the Set-PnPTraceLog -On -Level Debug on, and if I add the flag -ExcludeHandlers PageContents it runs with no error. I.E:

Get-PnPProvisioningTemplate -ExcludeHandlers PageContents -Out $ptoTemplate

Even if I revert the Home.aspx to version created by the System version, it remains broken.

I am trying to build a template of a "Modern Team Site" if anyone think that might matter.

--

Additional information, I also ran the commands:

Connect-PnPOnline -Url https://balhblah.sharepoint.com/sites/TemplateSite
Enable-PnPFeature -Identity 0c8a9a47-22a9-4798-82f1-00e62a96006e -Scope site

So that I could enable the Content Organizer Drop Off Library on the site.

I was really just trying to add that Drop Off lib to the Home page when I discovered this issue. Not sure if that is somehow related.

Thanks in advance!

  • Daniel - I'm seeing the identical behavior in one tenant but not in another tenant. I noticed a specific bug related to this logged in the PnP github, but that was specific to using some custom SPFx web parts. So that does not apply to my scenario. If I take the default modern team site, and simple edit the Quick Links web part to add a link to bing.com (to avoid the '"Home.aspx" has not been modified so there is no need to extract it' message), I still get the Null Reference error, same as with my actual site which has a few other OOB web parts. But the identical powershell script referencing – Tom Castiglia Jan 10 at 6:52
  • @TomCastiglia - Thanks for validating that I am not crazy, frustrating as it might be. When I first started creating these templates I was able to capture a customized Home.aspx, but was before I played around with HUB sites. I thought maybe if a site had a Hub site association (which adds a Nav bar to the top of all child hubs) that THAT might be causing this error in some form. Alas, my testing didn't confirm that. Removing site from a Hub, and trying to build template then, does not fix the issue. SHM... – Daniel W Jan 11 at 13:46
0

The command Get-PnPProvisioningTemplate generates a provisioning site template from a web.

The command can work for a site. It cannot work for a Home.aspx page.

Could you please provide the whole PnP script when you use the command Get-PnPProvisioningTemplate?

More reference:

Get-PnPProvisioningTemplate.

  • The only commands in my script: Set-PnPTraceLog -On -Level Debug - Connect-PnPOnline -Url https://balhblah.sharepoint.com/sites/TemplateSite -Credential $credentials - Get-PnPProvisioningTemplate -Out $ptoTemplate – Daniel W Dec 18 '18 at 13:57
  • On a fresh team site with no edites, when the TraceLog gets to the [PageContents], it says: -- "Home.aspx" has not been modified so there is no need to extract it. -- So not really sure what you mean by "It cannot work for Home.aspx page" I am tring to template the whole site. I have reviewed the pnp documentation, but am afraid it does not shed much light on my understanding of the issue. Thanks for your response @Amy_MSFT ! – Daniel W Dec 18 '18 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.