Add ability to selectively export a complete list or document library provisioning template.
Commandlet:
Get-PnPListProvisioningTemplate
Parameters:
ListPath (export template path)IncludeDataRows IncludeFiles (should save files and folders)IncludeWebparts IncludeContentTypesIncludeFieldsIncludeSecurityIncludeColumnDefaultsIncludeValidationSettingsIncludeItemSchedulingIncludeMangedNavigationSettingsIncludeWorkflowSettingsIncludeEnterpriseMetadataSettingsIncludeInformationPolicySettingsIncludePropertyBagPropertiesIncludeDataSetSettingsThis functionality will allow to selectively export lists and document libraries along with all associated configurations.
N/A
Hi Ruslan,
Did you find a solution for this? does it resolved yet? Are we able to "save as a template" a custom list or library in Modern SP sites and then build new-list (library) based on our custom template in another SP team site (O365 group)?
Thanks
@ehsan-hakimi I proposed the enhancement, but I do not think any work has been done. My workaround is to export the whole site and selectively manually transfer elements of interest into the target template set. It takes time and human errors are common. But, it is doable. It would have been nice to have it automated because often we need to deploy incremental changes.
@ruslanurban Thanks so much, Yes I am deleting lines from template.xml now. Our scenario is even simpler. We just using OOTB modern team site and want to add one custom document library to it. Exactly the same action called "save list/library as a template" on SP 2013 and then deploy that template on a new sites collection.
+1 for this request. Also it would be great to have an ability to export lists/doclibs content also with Get-PnPProvisioningTemplate cmdlet.
+1 for this request.
Try to use this script to get a template of a specific list.
$listName - the name of the list.
$outputTemplateFileName - the location of output template file
$listName = "EmployeesTest999";
$outputTemplateFileName = "D:\Temp\template.xml";
$template = Get-PnPProvisioningTemplate -OutputInstance -Handlers Lists
$listTemplate = $template.Lists | Where-Object { $_.Title -eq $listName }
$template.Lists.Clear()
$template.Lists.Add($listTemplate)
Save-PnPProvisioningTemplate -InputInstance $template -Out $outputTemplateFileName
Thank you for your suggestion @antonkhrit. That is not exactly what I was looking for, and there are a few issues with this approach:
Hi @ruslanurban,
I just demonstrated the way to extract specific artifacts from a template programmatically.
Not efficient, but you can wait some time to get a template. Not a big deal.
Only list definition is extracted in my case. This is just a general approach to extract specific entities from a template. You can modify the code to include more artifacts in a template.
For example, you can grab the template of the whole site, then remove only unnecessary lists and keep site fields, etc.
Your own workaround above is grabbing the whole template and removing not required entities manually. I did the same, but in a bit more elegant, programmatic way.
Still, a commandlet from PnP team that would allow us to do this, would be great.
Most helpful comment
+1 for this request.