PnP Provisioning Engine - Apply-SPOProvisioningTemplate Fails On Subweb (Powershell)

Copper Contributor

Hello, I am working with the provisioning engine and it's working perfectly on site collection level. But when I try to apply a template to a subsite, it fails with an error message I can't decipher. I've checked the SPO trace log and it's not giving me anything helpful to troubleshoot. I'm unsure how to fix this. I don't know what the null value with parameter name of source is referring to. Any ideas what could be causing this? I tried the code in C# with same results. Here is trace log:


Provisioning.vshost.exe Information: 0 : 2016-09-01 15:26:03.4671 [OfficeDevPnP.Core] [0] [Information] File template.xml retrieved from folder Benefits 0ms 'Provisioning.vshost.exe' (CLR v4.0.30319: Provisioning.vshost.exe): Loaded 'Microsoft.GeneratedCode'. Exception thrown: 'System.ArgumentNullException' in System.Core.dll



And this is the exception message:


Apply-SPOProvisioningTemplate : Value cannot be null.
Parameter name: source
At line:1 char:1
+ Apply-SPOProvisioningTemplate -Path C:\vs_prov\Benefits\template.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-SPOProvisioningTemplate], ArgumentNullException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Branding.ApplyProvisioningTemplate



Thank you very much for any help you can provide.

5 Replies
I usually get this error if one of the artefacts is missing. Are you sure that all artefacts used by the template is in the right folder as referenced by the template ?

What's the version of PnP PowerShell you're using? We've recently been fixing a few issues related to provisioning subsites...can you repro this using the latest version?

Update: Fixed (kind of)


I was using 2.6.1608.0


I checked and all of the local files that are referenced by the template are located in the folder.


I was able to fix this by getting the template with GetProvisioningTemplate provided by the PnP C# sample Provisioning.Framework.Console. Previously I was referencing an .xml file I got with the PowerShell cmdlet and then running C# method on that outputted file. I don't know what makes this C# method different than referencing a previously created xml file


I'm still not able to use the .xml file I created with PowerShell cmdlet but when I get template directly and reference it from memory, it works.


The original plan was to reference a previously created XML file but this works for the time being.




hmm...both should work. Can you log an issue in our pnp sites core issue list, including the XML you're reading?




I am also getting the below error and nothing get created in sub site using PnP provision commands.


Connect-SPOnline -Url  -Credential  DEV #(Get-Credential)

Apply-SPOProvisioningTemplate  -Path .\RetailerExtranetQARootSubSiteSiteStructureToTSW_2.xml 




Error :

Apply-SPOProvisioningTemplate : Value cannot be null.
Parameter name: stream
At line:1 char:1
+ Apply-SPOProvisioningTemplate -Path .\RetailerExtranetQASubSiteStruc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Apply-PnPProvisioningTemplate], ArgumentNullException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate