PnP PowerShell - PnP Provisioning package (pnp) with folders

%3CLINGO-SUB%20id%3D%22lingo-sub-45776%22%20slang%3D%22en-US%22%3EPnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45776%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20create%20a%20pnp%20provisioning%20file%20with%20a%20folder%20structure%20for%20a%20library%20by%20using%26nbsp%3BConvert-PnPFolderToProvisioningTemplate%20or%20doesn't%20the%20current%20provisioning%20enging%20support%20pnp%20packages%20with%20folders%3F%20I%20have%20tried%20with%20several%20options%20but%20with%20no%20success.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20the%20whole%20package%20to%20contain%20the%20folders%20from%20the%20beginning%20avoiding%20to%20have%20to%20handle%20that%20separately%20when%20the%20template%20has%20been%20applied%20to%20the%20site.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FNiclas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-45776%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47848%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47848%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Paul%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%40ErwinVanHunen's%20Blog%20says%20this%20is%20the%20call%20you%20make%20for%20the%20extension%20-%26gt%3B%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Epublic%20void%20ProcessRequest(ClientContext%20ctx%2C%20ProvisioningTemplate%20template%2C%20string%20configurationData)%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EYour%20code%20has%20this%20-%26gt%3B%3CBR%20%2F%3Eprivate%26nbsp%3Bvoid%26nbsp%3BCreateFolders(ClientContext%26nbsp%3Bcontext%2C%26nbsp%3BWeb%26nbsp%3Bweb%2C%26nbsp%3BList%26nbsp%3Blist%2C%26nbsp%3BProject.Provisioning.Models.ListConfigurationListFolder%5B%5D%26nbsp%3Bfolders)%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3ESo%20I%20presume%20I%20have%20to%20convert%20between%20the%20two.%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EI%20can%20get%20web%20from%20the%20clientcontext%20but%26nbsp%3Bfor%20the%20list%20I%20need%20to%20have%20the%20list%20name.%26nbsp%3B%20Where%20do%20I%20get%20that%20from%20%3F%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EThanks%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3ENigel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47203%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47203%22%20slang%3D%22en-US%22%3E%3CP%3EYep%20I%20guess%20that%20I%20have%20to%20look%20at%20a%20custom%20extension.%20Too%20bad%20as%20it%20would%20have%20been%20nice%20if%20the%20Convert-PnPFolderToProvisioningTemplate%20command%20had%20packaged%20the%20files%20and%20folders%20in%20the%20same%20pnp%20package.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FNiclas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47201%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47201%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20used%20the%20sample%20ProvisioningSchema-2016-05-DirectorySample.xml%20provided%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Provisioning-Schema%2Ftree%2Fmaster%2FSamples%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20and%20it%20doesn't%20seem%20like%20the%20Convert-PnPFolderToProvisioningTemplate%20take%20the%20files%20in%20consideration%20when%20the%20package%20is%20made.%20I%20have%20referenced%20the%20files%20like%20this%20in%20the%20xml%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%20%20%26lt%3Bpnp%3AFiles%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bpnp%3ADirectory%20src%3D%22c%3A%5Ctemp%5CDirectoryBulkLoadSample%22%20Folder%3D%22BulkLoaded%22%20Overwrite%3D%22true%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Recursive%3D%22true%22%20IncludedExtensions%3D%22*.docx%2C*.pdf%22%20ExcludedExtensions%3D%22*.xml%2C*.txt%22%0A%20%20%20%20%20%20%20%20%20%20%20%20MetadataMappingFile%3D%22c%3A%5CBulkLoadedMetadata.json%22%20%2F%26gt%3B%0A%20%20%20%20%20%20%26lt%3B%2Fpnp%3AFiles%26gt%3B%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47136%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47136%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Paul%20-%20very%20interesting%20-%20I%20will%20have%20to%20give%20it%20a%20go.%26nbsp%3B%20I%20have%20been%20looking%20to%20be%20able%20to%20this%20for%20a%20while.%26nbsp%3B%20Should%20there%20not%20be%20something%20in%20the%20pnp%20provisioning%26nbsp%3Btemplate%20which%20links%20your%20%26lt%3B...%26gt%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47101%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47101%22%20slang%3D%22en-US%22%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CP%3Ehi%20Nigel%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20my%20code%20i%20did%20a%20big%20one%20this%20is%20a%20extract%20of%20the%20template%3A%3C%2FP%3E%3CPRE%3E%20%20%20%26lt%3Bdef%3AListConfiguration%20xmlns%3Adef%3D%22http%3A%2F%2Ftempuri.org%2FListConfiguration%22%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3ASiteUrl%26gt%3B%7Bparameter%3ASiteCollectionUrl%7D%26lt%3B%2Fdef%3ASiteUrl%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3ALists%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3AList%20Url%3D%22COM%22%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3AFolders%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3AFolder%20Title%3D%22Estimates%22%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3AObjectSecurity%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3ABreakRoleInheritance%20ClearSubscopes%3D%22false%22%20CopyRoleAssignments%3D%22true%22%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Bdef%3ARoleAssignment%20Principal%3D%22Estimators%22%20RoleDefinition%3D%22ContributeWithoutDelete%22%2F%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fdef%3ABreakRoleInheritance%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fdef%3AObjectSecurity%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fdef%3AFolder%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fdef%3AFolders%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3B%2Fdef%3AList%26gt%3B%0A%26lt%3B%2Fdef%3ALists%26gt%3B%0A%26lt%3B%2Fdef%3AListConfiguration%26gt%3B%20%20%20%20%3C%2FPRE%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47022%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47022%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Paul%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20would%20the%20provisioning%20Template%20entries%20look%20like%20to%20support%20the%20folder%20hierarchy%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENigel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-46016%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-46016%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20could%20create%20a%20extention%20in%20your%20template%20and%20use%20this%20code%3A%3C%2FP%3E%3CP%3ESnippet%3C%2FP%3E%3CPRE%3E%3CSPAN%3Eprivate%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Evoid%3C%2FSPAN%3E%26nbsp%3BCreateFolders(%3CSPAN%3EClientContext%3C%2FSPAN%3E%26nbsp%3Bcontext%2C%26nbsp%3B%3CSPAN%3EWeb%3C%2FSPAN%3E%26nbsp%3Bweb%2C%26nbsp%3B%3CSPAN%3EList%3C%2FSPAN%3E%26nbsp%3Blist%2C%26nbsp%3BProject%3CSPAN%3E.%3C%2FSPAN%3EProvisioning%3CSPAN%3E.%3C%2FSPAN%3EModels%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EListConfigurationListFolder%3C%2FSPAN%3E%5B%5D%26nbsp%3Bfolders)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eforeach%3C%2FSPAN%3E%26nbsp%3B(%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3Bfolder%26nbsp%3B%3CSPAN%3Ein%3C%2FSPAN%3E%26nbsp%3Bfolders)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3EListItem%3C%2FSPAN%3E%26nbsp%3BnewItem%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Etry%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E%2F%2F%26nbsp%3BCreate%26nbsp%3Bfolder%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3EListItemCreationInformation%3C%2FSPAN%3E%26nbsp%3BitemCreateInfo%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Enew%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3EListItemCreationInformation%3C%2FSPAN%3E()%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BitemCreateInfo%3CSPAN%3E.%3C%2FSPAN%3EUnderlyingObjectType%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3EFileSystemObjectType%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3EFolder%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BitemCreateInfo%3CSPAN%3E.%3C%2FSPAN%3ELeafName%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bfolder%3CSPAN%3E.%3C%2FSPAN%3ETitle%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BnewItem%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Blist%3CSPAN%3E.%3C%2FSPAN%3EAddItem(itemCreateInfo)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BnewItem%5B%3CSPAN%3E%22Title%22%3C%2FSPAN%3E%5D%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bfolder%3CSPAN%3E.%3C%2FSPAN%3ETitle%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BnewItem%3CSPAN%3E.%3C%2FSPAN%3EUpdate()%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3EExecuteQueryRetry()%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Ecatch%3C%2FSPAN%3E%26nbsp%3B(%3CSPAN%3EException%3C%2FSPAN%3E%26nbsp%3Be)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3ETraceHelper%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3EWriteInformationToListener(%3CSPAN%3E%22LogFile%22%3C%2FSPAN%3E%2C%26nbsp%3B%3CSPAN%3E%24%22Couldn't%26nbsp%3Bcreate%26nbsp%3Bfolder%3A%26nbsp%3B%3C%2FSPAN%3E%7Bfolder%3CSPAN%3E.%3C%2FSPAN%3ETitle%7D%3CSPAN%3E.%22%3C%2FSPAN%3E)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Econtinue%3C%2FSPAN%3E%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eif%3C%2FSPAN%3E%26nbsp%3B(folder%3CSPAN%3E.%3C%2FSPAN%3EObjectSecurity%26nbsp%3B%3CSPAN%3E!%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Enull%3C%2FSPAN%3E)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E%2F%2F%26nbsp%3BSet%26nbsp%3Bitem%26nbsp%3Bsecurity%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3BsecuritySettings%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bfolder%3CSPAN%3E.%3C%2FSPAN%3EObjectSecurity%3CSPAN%3E.%3C%2FSPAN%3EBreakRoleInheritance%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eif%3C%2FSPAN%3E%26nbsp%3B(securitySettings%3CSPAN%3E.%3C%2FSPAN%3ERoleAssignment%3CSPAN%3E.%3C%2FSPAN%3ELength%26nbsp%3B%3CSPAN%3E%3D%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3E0%3C%2FSPAN%3E)%26nbsp%3B%3CSPAN%3Econtinue%3C%2FSPAN%3E%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Etry%3C%2FSPAN%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3Bgroups%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3ELoadQuery(context%3CSPAN%3E.%3C%2FSPAN%3EWeb%3CSPAN%3E.%3C%2FSPAN%3ESiteGroups%3CSPAN%3E.%3C%2FSPAN%3EInclude(g%26nbsp%3B%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%26nbsp%3Bg%3CSPAN%3E.%3C%2FSPAN%3ELoginName))%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3BwebRoleDefinitions%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3ELoadQuery(context%3CSPAN%3E.%3C%2FSPAN%3EWeb%3CSPAN%3E.%3C%2FSPAN%3ERoleDefinitions)%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3EExecuteQueryRetry()%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BnewItem%3CSPAN%3E.%3C%2FSPAN%3EBreakRoleInheritance(securitySettings%3CSPAN%3E.%3C%2FSPAN%3ECopyRoleAssignments%2C%26nbsp%3BsecuritySettings%3CSPAN%3E.%3C%2FSPAN%3EClearSubscopes)%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eforeach%3C%2FSPAN%3E%26nbsp%3B(%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3BroleAssignment%26nbsp%3B%3CSPAN%3Ein%3C%2FSPAN%3E%26nbsp%3BsecuritySettings%3CSPAN%3E.%3C%2FSPAN%3ERoleAssignment)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3EPrincipal%3C%2FSPAN%3E%26nbsp%3Bprincipal%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bgroups%3CSPAN%3E.%3C%2FSPAN%3EFirstOrDefault(g%26nbsp%3B%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%26nbsp%3Bg%3CSPAN%3E.%3C%2FSPAN%3ELoginName%26nbsp%3B%3CSPAN%3E%3D%3D%3C%2FSPAN%3E%26nbsp%3BroleAssignment%3CSPAN%3E.%3C%2FSPAN%3EPrincipal)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eif%3C%2FSPAN%3E%26nbsp%3B(principal%26nbsp%3B%3CSPAN%3E%3D%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Enull%3C%2FSPAN%3E)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bprincipal%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3EWeb%3CSPAN%3E.%3C%2FSPAN%3EEnsureUser(roleAssignment%3CSPAN%3E.%3C%2FSPAN%3EPrincipal)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3BroleDefinitionBindingCollection%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Enew%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3ERoleDefinitionBindingCollection%3C%2FSPAN%3E(context)%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Evar%3C%2FSPAN%3E%26nbsp%3BroleDefinition%26nbsp%3B%3CSPAN%3E%3D%3C%2FSPAN%3E%26nbsp%3BwebRoleDefinitions%3CSPAN%3E.%3C%2FSPAN%3EFirstOrDefault(r%26nbsp%3B%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%26nbsp%3Br%3CSPAN%3E.%3C%2FSPAN%3EName%26nbsp%3B%3CSPAN%3E%3D%3D%3C%2FSPAN%3E%26nbsp%3BroleAssignment%3CSPAN%3E.%3C%2FSPAN%3ERoleDefinition)%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Eif%3C%2FSPAN%3E%26nbsp%3B(roleDefinition%26nbsp%3B%3CSPAN%3E!%3D%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3Enull%3C%2FSPAN%3E)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BroleDefinitionBindingCollection%3CSPAN%3E.%3C%2FSPAN%3EAdd(roleDefinition)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BnewItem%3CSPAN%3E.%3C%2FSPAN%3ERoleAssignments%3CSPAN%3E.%3C%2FSPAN%3EAdd(principal%2C%26nbsp%3BroleDefinitionBindingCollection)%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcontext%3CSPAN%3E.%3C%2FSPAN%3EExecuteQueryRetry()%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Ecatch%3C%2FSPAN%3E%26nbsp%3B(%3CSPAN%3EException%3C%2FSPAN%3E%26nbsp%3Be)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3ETraceHelper%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3EWriteInformationToListener(%3CSPAN%3E%22LogFile%22%3C%2FSPAN%3E%2C%26nbsp%3B%3CSPAN%3E%22Error%26nbsp%3Boccured%26nbsp%3Bwhen%26nbsp%3Bsetting%26nbsp%3Bitemlevel%26nbsp%3Bsecurity%26nbsp%3Bon%26nbsp%3Bfolder.%22%3C%2FSPAN%3E)%3B%0A%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3Econtinue%3C%2FSPAN%3E%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45887%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20PowerShell%20-%20PnP%20Provisioning%20package%20(pnp)%20with%20folders%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45887%22%20slang%3D%22en-US%22%3EAccording%20to%20a%20comment%20in%20this%20post%2C%20it%20seems%20possible%3A%3CBR%20%2F%3E%3CA%20href%3D%22http%3A%2F%2Fnickvandenheuvel.eu%2F2016%2F03%2F04%2Fextract-and-apply-templates-with-office-dev-pnp-provisioning-powershell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fnickvandenheuvel.eu%2F2016%2F03%2F04%2Fextract-and-apply-templates-with-office-dev-pnp-provisioning-powershell%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EHow%20are%20you%20referencing%20the%20Files%3F%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi 

 

Is it possible to create a pnp provisioning file with a folder structure for a library by using Convert-PnPFolderToProvisioningTemplate or doesn't the current provisioning enging support pnp packages with folders? I have tried with several options but with no success. 

 

I would like the whole package to contain the folders from the beginning avoiding to have to handle that separately when the template has been applied to the site. 

 

/Niclas

8 Replies
Highlighted
According to a comment in this post, it seems possible:
http://nickvandenheuvel.eu/2016/03/04/extract-and-apply-templates-with-office-dev-pnp-provisioning-p...

How are you referencing the Files?
Highlighted

You could create a extention in your template and use this code:

Snippet

private void CreateFolders(ClientContext context, Web web, List list, Project.Provisioning.Models.ListConfigurationListFolder[] folders)
      {
          foreach (var folder in folders)
          {
              ListItem newItem;
 
              try
              {
                  // Create folder
                  ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
 
                  itemCreateInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
                  itemCreateInfo.LeafName = folder.Title;
 
                  newItem = list.AddItem(itemCreateInfo);
                  newItem["Title"= folder.Title;
                  newItem.Update();
                  context.ExecuteQueryRetry();
              }
              catch (Exception e)
              {
                  TraceHelper.WriteInformationToListener("LogFile"$"Couldn't create folder: {folder.Title}.");
                  continue;
              }
 
              if (folder.ObjectSecurity != null)
              {   // Set item security
                  var securitySettings = folder.ObjectSecurity.BreakRoleInheritance;
 
                  if (securitySettings.RoleAssignment.Length == 0continue;
 
                  try
                  {
 
                      var groups = context.LoadQuery(context.Web.SiteGroups.Include(g => g.LoginName));
                      var webRoleDefinitions = context.LoadQuery(context.Web.RoleDefinitions);
 
                      context.ExecuteQueryRetry();
 
                      newItem.BreakRoleInheritance(securitySettings.CopyRoleAssignments, securitySettings.ClearSubscopes);
 
                      foreach (var roleAssignment in securitySettings.RoleAssignment)
                      {
                          Principal principal = groups.FirstOrDefault(g => g.LoginName == roleAssignment.Principal);
                          if (principal == null)
                          {
                              principal = context.Web.EnsureUser(roleAssignment.Principal);
                          }
 
                          var roleDefinitionBindingCollection = new RoleDefinitionBindingCollection(context);
 
                          var roleDefinition = webRoleDefinitions.FirstOrDefault(r => r.Name == roleAssignment.RoleDefinition);
 
                          if (roleDefinition != null)
                          {
                              roleDefinitionBindingCollection.Add(roleDefinition);
                          }
                          newItem.RoleAssignments.Add(principal, roleDefinitionBindingCollection);
                      }
                      context.ExecuteQueryRetry();
                  }
                  catch (Exception e)
                  {
                      TraceHelper.WriteInformationToListener("LogFile""Error occured when setting itemlevel security on folder.");
 
                      continue;
                  }
              }
          }
      }
Highlighted

Hi Paul

 

What would the provisioning Template entries look like to support the folder hierarchy?

 

Regards

 

Nigel

Highlighted

hi Nigel,

 

in my code i did a big one this is a extract of the template:

   <def:ListConfiguration xmlns:def="http://tempuri.org/ListConfiguration">
              <def:SiteUrl>{parameter:SiteCollectionUrl}</def:SiteUrl>
              <def:Lists>
                <def:List Url="COM">
                  
                  <def:Folders>
                    <def:Folder Title="Estimates">
                      <def:ObjectSecurity>
                        <def:BreakRoleInheritance ClearSubscopes="false" CopyRoleAssignments="true">
                          <def:RoleAssignment Principal="Estimators" RoleDefinition="ContributeWithoutDelete"/>
                        </def:BreakRoleInheritance>
                      </def:ObjectSecurity>
                    </def:Folder>
                  </def:Folders>
                </def:List>
</def:Lists>
</def:ListConfiguration>    
Highlighted

Thanks Paul - very interesting - I will have to give it a go.  I have been looking to be able to this for a while.  Should there not be something in the pnp provisioning template which links your <def:...   to your code ?

Highlighted

Hi

 

I have used the sample ProvisioningSchema-2016-05-DirectorySample.xml provided here and it doesn't seem like the Convert-PnPFolderToProvisioningTemplate take the files in consideration when the package is made. I have referenced the files like this in the xml file.

 

  <pnp:Files>
        <pnp:Directory src="c:\temp\DirectoryBulkLoadSample" Folder="BulkLoaded" Overwrite="true"
            Recursive="true" IncludedExtensions="*.docx,*.pdf" ExcludedExtensions="*.xml,*.txt"
            MetadataMappingFile="c:\BulkLoadedMetadata.json" />
      </pnp:Files>
Highlighted

Yep I guess that I have to look at a custom extension. Too bad as it would have been nice if the Convert-PnPFolderToProvisioningTemplate command had packaged the files and folders in the same pnp package.

 

/Niclas

Highlighted

Hi Paul
 
@ErwinVanHunen's Blog says this is the call you make for the extension ->   


public void ProcessRequest(ClientContext ctx, ProvisioningTemplate template, string configurationData)
 
Your code has this ->
private void CreateFolders(ClientContext context, Web web, List list, Project.Provisioning.Models.ListConfigurationListFolder[] folders)
 
So I presume I have to convert between the two.
 
I can get web from the clientcontext but for the list I need to have the list name.  Where do I get that from ?
 
Thanks
 
Nigel