Error when trying to create site template using Get-PnPProvisioningTemplate

%3CLINGO-SUB%20id%3D%22lingo-sub-38083%22%20slang%3D%22en-US%22%3EError%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-38083%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20copy%20a%20template%20from%20a%20SPO%20existing%20site%20on%20my%20tenant%20and%20recieving%20the%20following%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EConnect-PnPOnline%20-url%20%22%3CA%20href%3D%22https%3A%2F%2Fmycustomtenant.sharepoint.com%2Fsites%2Fsptest%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmycustomtenant.sharepoint.com%2Fsites%2Fsptest%3C%2FA%3E%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CEM%3EGet-PnPProvisioningTemplate%20-force%20-out%20%22C%3A%5CSPOTemplates%5CSPOProject.xml%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EGet-PnPProvisioningTemplate%20%3A%20Object%20reference%20not%20set%20to%20an%20instance%20of%20an%0Aobject.%0AAt%20line%3A1%20char%3A1%0A%2B%20Get-PnPProvisioningTemplate%20-force%20-out%20%22C%3A%5CSPOTemplates%5CSPOProject.xml%22%0A%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%0A%20%20%20%20%2B%20CategoryInfo%20%20%20%20%20%20%20%20%20%20%3A%20WriteError%3A%20(%3A)%20%5BGet-PnPProvisioningTemplate%5D%2C%20N%0A%20%20%20ullReferenceException%0A%20%20%20%20%2B%20FullyQualifiedErrorId%20%3A%20EXCEPTION%2CSharePointPnP.PowerShell.Commands.Prov%0A%20%20%20isioning.GetProvisioningTemplate%3C%2FPRE%3E%3CP%3EVisually%2C%20I%20can%20see%20that%20it%20fails%20during%20working%20on%20%22List%20instances%22%20but%20is%20there%20any%20way%20to%20debug%2Fanalyze%20and%20fix%20the%20problem%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-38083%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-161965%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-161965%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20facing%20the%20same%20issue%20-%20failing%20on%20List%20Instances%20here%20as%20well.%20Looks%20like%20the%26nbsp%3Bissue%20has%20been%20reported%20on%20Github%2C%20but%20there%20is%20no%20known%20solution%20yet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fissues%2F1298%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fissues%2F1298%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-39170%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-39170%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Peiter%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEven%20without%20parameters%2C%20it%20still%20fails%20while%20trying%20to%20process%20%22List%20instances%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20689px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F9867iBA545B5AA1715EC5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ErrorGetProvisioningTemplateSPO.png%22%20title%3D%22ErrorGetProvisioningTemplateSPO.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-38297%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-38297%22%20slang%3D%22en-US%22%3E%3CP%3ECan%20you%20run%20Get-PnPProvisioingTemplate%20without%20any%20parameters%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20looks%20like%20writing%20to%20the%20file%20is%20failing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-38284%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-38284%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Paul%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am.%20I%20assume%20the%20issue%20might%20be%20with%20one%20of%20the%20lists%20in%20the%20site%20which%20I%20am%20trying%20to%20convert%20into%20a%20site%20template.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20am%20debugging%20in%20Powershell%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESet-SPOTraceLog%20-On%20-Level%20Debug%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20then%20running%20the%20Provisioning%20command%20to%20see%20where%20it%20fails%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EGet-SPOProvisioningTemplate%20-Handler%20Fields%20-Out%20c%3A%5Ctemp%5Ctest.xml%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20let%20me%20know%20if%20I%20am%20on%20the%20right%20path%2C%20or%20I%20should%20be%20attempting%20something%20else.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-38136%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20when%20trying%20to%20create%20site%20template%20using%20Get-PnPProvisioningTemplate%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-38136%22%20slang%3D%22en-US%22%3E%3CP%3EDo%20you%20use%20the%20latest%20PNP%20powershell%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D35588%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D35588%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted
Highlighted

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!

Highlighted

Can you run Get-PnPProvisioingTemplate without any parameters?

 

It looks like writing to the file is failing.

Highlighted

Hi Peiter,

 

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

 

 ErrorGetProvisioningTemplateSPO.png

Highlighted

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