PNP Template Provisioning Document Sets

%3CLINGO-SUB%20id%3D%22lingo-sub-287418%22%20slang%3D%22en-US%22%3EPNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287418%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20PNP%20Provisioning%20template%20of%20a%20site%20and%20then%20apply%20this%20to%20other%20modern%20sites%2C%20but%20one%20of%20the%20content%20types%20on%20it%20is%20not%20playing%20ball.%20It's%20a%20document%20set%20and%20in%20the%20properties%20it%20has%20default%20content%20of%205%20files%20to%20create%205%20folders.%20I%20don't%20need%20the%20files%20but%2C%20at%20least%20through%20the%20GUI%2C%20you%20have%20to%20put%20dummy%20files%20in%20to%20create%205%20folders%20automatically%20when%20the%20document%20set%20is%20created%2C%20which%20is%20the%20brief.%20When%20I%20create%20the%20provisioning%20XML%2C%20all%20the%20default%20files%20are%20stripped%20out%20of%20the%20document%20set%20content%20type.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20I%20go%20about%20doing%20this%20in%20PNP%3F%20I%20would%20settle%20for%20how%20to%20do%20this%20in%20PowerShell%20against%20an%20SPOSite%2C%20as%20I%20could%20run%20it%20after%20creation%20of%20the%20main%20sites%20from%20the%20templates.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-287418%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Edocumentset%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eprovisioning%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362639%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362639%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20not%20sure%20you%20can%20provision%20folders%20like%20that%20within%20document%20sets%20in%20the%20Provisioning%20Schema.%20I%20think%20you%20might%20have%20to%20go%20edit%20the%20document%20set%20content%20type's%20Welcome%20Page%20property%20with%20PowerShell%20after%20it%20has%20been%20created%20in%20order%20to%20do%20that%20-%20not%20100%25%20whether%20you%20can%20even%20do%20that%20or%20not.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-362595%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-362595%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20so%20much%20for%20this%2C%20it%20works%20beautifully%20now.%20I'm%20using%20the%20solution%20to%20create%20Document%20sets%20containing%205%20folders%20automatically%2C%20so%20through%20the%20interface%20I%20upload%20a%20dummy%20file%20to%20each%20folder%20path.%20Can%20this%20also%20be%20done%20using%20the%20PNP%20template%20as%20I%20don't%20see%20anywhere%20to%20enter%20the%20folder%20path%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-361236%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-361236%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20the%20default%20document%20will%20be%20the%20path%20to%20an%20actual%20document%20that%20you%20will%20include%20in%20the%20same%20folder%20as%20your%20template.xml%20file.%20So%20let's%20say%20you%20create%20a%20folder%20on%20your%20c%3A%20drive%20called%20%22mypnptemplate%22%20and%20inside%20it%20you%20have%20your%20some%20files%20such%20as%20%22Attendance.txt%22%2C%20along%20with%20the%20provisioning%20template%20itself%2C%20%22template.xml%22%2C%20which%20references%20those%20within%20that%20same%20folder%20using%20the%20relative%20path%20(eg.%20.%2FAttendance.txt)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20would%20then%20%22zip%22%20that%20folder%20up%20as%20a%20PnP%20package%20file%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20with%20PnP%20PowerShell%2C%20you%20run%3A%20Convert-PnPFolderToProvisioningTemplate%20-Out%20template.pnp%20-Folder%20c%3A%5Cmypnptemplate%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20need%20to%20name%20the%20.pnp%20file%20the%20same%20as%20the%20.xml%20file%20within%20the%20folder%20via%20the%20%22-Out%22%20parameter.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20will%20create%20a%20.pnp%20package%20file%20-%20an%20Open%20XML%20file%20-%20including%20your%20artifacts%20(documents%20in%20your%20case)%20and%20references%20to%20them%20within%20the%20provisioning%20template.%20If%20you%20then%20Apply-PnPProvisioningTemplate%20using%20the%20.pnp%20file%2C%20you%20will%20provision%20your%20template%20along%20with%20the%20included%20artifacts%20(documents).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EConvert-PnPFolderToProvisioningTemplate%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fconvert-pnpfoldertoprovisioningtem%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fconvert-pnpfoldertoprovisioningtem%3C%2FA%3E...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EFull%20details%20about%20PnP%20Package%20files%20and%20including%20artifacts%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.erwinmcm.com%2Fgetting-started-with-the-pnp-provisioning-engine-and-pnp-powershell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.erwinmcm.com%2Fgetting-started-with-the-pnp-provisioning-engine-and-pnp-powershell%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-360403%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-360403%22%20slang%3D%22en-US%22%3E%3CP%3EI%20think%20you%20might%20be%20able%20to%20put%20a%20folder%20name%20in%20the%20Name%20field%2C%20before%20the%20filename%2C%20but%20the%20bit%20I%20still%20don't%20understand%20is%20where%20the%20FileSourcePath%20to%20the%20file%20comes%20from.%20Is%20the%20file%20path%20on%20the%20file%20system%20with%20the%20template%20xml%20or%20on%20the%20target%20site%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CDEFAULTDOCUMENT%3E%3CSTRONG%3EName%3C%2FSTRONG%3E%3D%22Attendance.txt%22%20ContentTypeID%3D%220x010100FE20F6E69ED0FB40AFAA895B47A533D8%22%20%3CSTRONG%3EFileSourcePath%3D%22.%2Flibraries%2FAttendence.txt%22%20%2F%26gt%3B%3C%2FSTRONG%3E%3C%2FDEFAULTDOCUMENT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-291672%22%20slang%3D%22en-US%22%3ERe%3A%20PNP%20Template%20Provisioning%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-291672%22%20slang%3D%22en-US%22%3E%3CP%3ENot%20sure%20if%20it%20helps%20your%20exact%20case%2C%20but%20if%20you%20look%20at%20the%20latest%20PnP%20Provisioning%20Schema%20at%20line%20310%2C%20you%20can%20see%20how%20to%20handle%20document%20sets%20with%20default%20content.%26nbsp%3BThe%20sample%20doesn't%20seem%20to%20include%20any%20default%20folders%2C%20but%26nbsp%3Bmaybe%20you%20can%20find%20something%20to%20help%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Provisioning-Schema%2Fblob%2Fmaster%2FSamples%2FProvisioningSchema-2018-07-FullSample-01.xml%23L310%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Provisioning-Schema%2Fblob%2Fmaster%2FSamples%2FProvisioningSchema-2018-07-FullSample-01.xml%23L310%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

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. 

5 Replies
Highlighted

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.

 

https://github.com/SharePoint/PnP-Provisioning-Schema/blob/master/Samples/ProvisioningSchema-2018-07...

Highlighted

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" />

Highlighted

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/

Highlighted

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?

Highlighted

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.