Error when trying to create site template using Get-PnPProvisioningTemplate

Copper Contributor

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


Connect-PnPOnline -url ""

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



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

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.



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"



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.