Error when trying to create site template using Get-PnPProvisioningTemplate

New Contributor

I am trying to copy a template from a SPO existing site on my tenant and recieving the following error:

 

Connect-PnPOnline -url "https://mycustomtenant.sharepoint.com/sites/sptest"


Get-PnPProvisioningTemplate -force -out "C:\SPOTemplates\SPOProject.xml"

 

 

Get-PnPProvisioningTemplate : Object reference not set to an instance of an
object.
At line:1 char:1
+ Get-PnPProvisioningTemplate -force -out "C:\SPOTemplates\SPOProject.xml"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Get-PnPProvisioningTemplate], N
   ullReferenceException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Prov
   isioning.GetProvisioningTemplate

Visually, I can see that it fails during working on "List instances" but is there any way to debug/analyze and fix the problem?

 

5 Replies

Hi Paul,

 

I am. I assume the issue might be with one of the lists in the site which I am trying to convert into a site template.

 

So I am debugging in Powershell

 

Set-SPOTraceLog -On -Level Debug

 

and then running the Provisioning command to see where it fails:

 

Get-SPOProvisioningTemplate -Handler Fields -Out c:\temp\test.xml

 

Do let me know if I am on the right path, or I should be attempting something else.

 

Thanks!

Can you run Get-PnPProvisioingTemplate without any parameters?

 

It looks like writing to the file is failing.

Hi Peiter,

 

Even without parameters, it still fails while trying to process "List instances"

 

 ErrorGetProvisioningTemplateSPO.png

I'm facing the same issue - failing on List Instances here as well. Looks like the issue has been reported on Github, but there is no known solution yet.

 

https://github.com/SharePoint/PnP-PowerShell/issues/1298