Forum Discussion
Robin Thakur
Nov 15, 2018Copper Contributor
PNP Template Provisioning Document Sets
I am trying to create a PNP Provisioning template of a site and then apply this to other modern sites, but one of the content types on it is not playing ball. It's a document set and in the propertie...
Thomas Berman
Nov 27, 2018Iron Contributor
Not sure if it helps your exact case, but if you look at the latest PnP Provisioning Schema at line 310, you can see how to handle document sets with default content. The sample doesn't seem to include any default folders, but maybe you can find something to help you.
Robin Thakur
Mar 05, 2019Copper Contributor
I think you might be able to put a folder name in the Name field, before the filename, but the bit I still don't understand is where the FileSourcePath to the file comes from. Is the file path on the file system with the template xml or on the target site?
<pnp:DefaultDocument Name="Attendance.txt" ContentTypeID="0x010100FE20F6E69ED0FB40AFAA895B47A533D8" FileSourcePath="./libraries/Attendence.txt" />
- Thomas BermanMar 06, 2019Iron Contributor
So the default document will be the path to an actual document that you will include in the same folder as your template.xml file. So let's say you create a folder on your c: drive called "mypnptemplate" and inside it you have your some files such as "Attendance.txt", along with the provisioning template itself, "template.xml", which references those within that same folder using the relative path (eg. ./Attendance.txt)
You would then "zip" that folder up as a PnP package file:
Then with PnP PowerShell, you run: Convert-PnPFolderToProvisioningTemplate -Out template.pnp -Folder c:\mypnptemplate
You need to name the .pnp file the same as the .xml file within the folder via the "-Out" parameter.
This will create a .pnp package file - an Open XML file - including your artifacts (documents in your case) and references to them within the provisioning template. If you then Apply-PnPProvisioningTemplate using the .pnp file, you will provision your template along with the included artifacts (documents).
Convert-PnPFolderToProvisioningTemplate:
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/convert-pnpfoldertoprovisioningtem...
Full details about PnP Package files and including artifacts:
https://www.erwinmcm.com/getting-started-with-the-pnp-provisioning-engine-and-pnp-powershell/
- Robin ThakurMar 07, 2019Copper Contributor
Thanks so much for this, it works beautifully now. I'm using the solution to create Document sets containing 5 folders automatically, so through the interface I upload a dummy file to each folder path. Can this also be done using the PNP template as I don't see anywhere to enter the folder path?
- Thomas BermanMar 07, 2019Iron Contributor
I'm not sure you can provision folders like that within document sets in the Provisioning Schema. I think you might have to go edit the document set content type's Welcome Page property with PowerShell after it has been created in order to do that - not 100% whether you can even do that or not.