Forum Discussion

Robin Thakur's avatar
Robin Thakur
Copper Contributor
Nov 15, 2018

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 properties it has default content of 5 files to create 5 folders. I don't need the files but, at least through the GUI, you have to put dummy files in to create 5 folders automatically when the document set is created, which is the brief. When I create the provisioning XML, all the default files are stripped out of the document set content type.

 

How do I go about doing this in PNP? I would settle for how to do this in PowerShell against an SPOSite, as I could run it after creation of the main sites from the templates. 

    • Robin Thakur's avatar
      Robin Thakur
      Copper 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 Berman's avatar
        Thomas Berman
        Iron 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/

Resources