Apply-PnPProvisioningTemplate error when providing URL to pnp file in SharePoint

%3CLINGO-SUB%20id%3D%22lingo-sub-78986%22%20slang%3D%22en-US%22%3EApply-PnPProvisioningTemplate%20error%20when%20providing%20URL%20to%20pnp%20file%20in%20SharePoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-78986%22%20slang%3D%22en-US%22%3E%3CP%3EI%20looked%20at%20the%20samples%20and%20source%20code%20and%20it%20does%20show%20you%20can%20use%20a%20SharePoint%20doc%20library%20to%20hold%20the%20XML%20template%20as%20a%20.pnp%20file%20when%20passing%20in%20the%20-Path%20parameter%2C%20however%20I%20am%20getting%20an%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EApply%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EPnPProvisioningTemplate%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EPath%20%3C%2FSPAN%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fmy.sharepoint.com%2Fsites%2Ftest%2Ftemplate.pnp%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmy.sharepoint.com%2Fsites%2Ftest%2Ftemplate.pnp%3C%2FA%3E%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EHandlers%20Navigation%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EClearNavigation%3A%3C%2FSPAN%3E%3CSPAN%3E%24true%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20get%20this%20error%20then%3A%20%26nbsp%3BObject%20reference%20not%20set%20to%20an%20instance%20of%20an%20object%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIt%20works%20fine%20if%20it%20is%20a%20local%20file%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EHas%20anyone%20successfully%20used%20the%20Apply-PnPProvisioningTemplate%20command%20with%20a%20SP%20URL%20for%20the%20path%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294185%22%20slang%3D%22en-US%22%3ERe%3A%20Apply-PnPProvisioningTemplate%20error%20when%20providing%20URL%20to%20pnp%20file%20in%20SharePoint%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294185%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20you%20ever%20get%20this%20to%20work.%26nbsp%3B%20I%20am%20revisiting%20some%20deployment%20scripts%20I%20successfully%20tested%20a%20few%20months%20ago%26nbsp%3B%20and%20I%20am%20getting%20the%20same%20error%20-%20I%20have%20created%20an%20issue%20on%20GIT%20to%20follow%20this%20up.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EApply-PnPProvisioningTemplate%20%3A%20Object%20reference%20not%20set%20to%20an%20instance%20of%20an%20object.%3CBR%20%2F%3EAt%20D%3A%5CDev%5CClients%5CWSL%5CThe%20Volt%20SP%20Starter%20Kit%20Non%20FR%5Cprovisioning%5CApply-WSLSiteDesignsOrScripts.ps1%3A69%20%3CBR%20%2F%3Echar%3A1%3CBR%20%2F%3E%2B%20Apply-PnPProvisioningTemplate%20-Path%20WSLProvisioningSDTemplate.xml%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%20%2B%20CategoryInfo%20%3A%20WriteError%3A%20(%3A)%20%5BApply-PnPProvisioningTemplate%5D%2C%20NullReferenceException%3CBR%20%2F%3E%20%2B%20FullyQualifiedErrorId%20%3A%20EXCEPTION%2CSharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTempl%20%3CBR%20%2F%3E%20ate%3C%2FPRE%3E%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I looked at the samples and source code and it does show you can use a SharePoint doc library to hold the XML template as a .pnp file when passing in the -Path parameter, however I am getting an error.

 

Apply-PnPProvisioningTemplate -Path https://my.sharepoint.com/sites/test/template.pnp -Handlers Navigation -ClearNavigation:$true
 
I get this error then:  Object reference not set to an instance of an object
 
It works fine if it is a local file
Has anyone successfully used the Apply-PnPProvisioningTemplate command with a SP URL for the path?
1 Reply
Highlighted

Hi

 

Did you ever get this to work.  I am revisiting some deployment scripts I successfully tested a few months ago  and I am getting the same error - I have created an issue on GIT to follow this up.

 

Apply-PnPProvisioningTemplate : Object reference not set to an instance of an object.
At D:\Dev\Clients\WSL\The Volt SP Starter Kit Non FR\provisioning\Apply-WSLSiteDesignsOrScripts.ps1:69
char:1
+ Apply-PnPProvisioningTemplate -Path WSLProvisioningSDTemplate.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], NullReferenceException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTempl
ate