This blog will show how to get a PnP template of a specific SharePoint list or document library and apply to another site collection using PnP provisioning engine.
Using PnP provisioning you can model a site by configuring the design of site columns, content types, list definitions and instances, composed looks, pages (either web part pages or wiki pages), and much more, via your web browser. When you are done with the design, you can export what you have done into a persistent provisioning template format.
PnP template is an XML file that contains a description of SharePoint elements (lists, libraries, pages, etc.) that will be created. You can create your own XML template for your SharePoint list or libraries. Then you can apply that template to as many target sites as you like.
The script below will help you to get a template of a specific list or library.
- Connect-PnPOnline -Url https:
- $listTitle = Read-Host "Enter title of the list or library"
- $outputTemplateFile = "ListTemplate.xml";
- $template = Get-PnPProvisioningTemplate -OutputInstance -Handlers Lists
- $listTemplate = $template.Lists | Where-Object { $_.Title -eq $listTitle }
- $template.Lists.Clear()
- $template.Lists.Add($listTemplate)
- Save-PnPProvisioningTemplate -InputInstance $template -Out $outputTemplateFile
Once you execute the script, you will have the template for your specific list or document library.
To apply the generated template back to another site you just need to run the "Apply-PnPProvisioningTemplate" cmdlet.
The script below will help you apply the template to another site.
Connect-PnPOnline-Url - https://tenant.sharepoint.com/sites/OtherSite
Apply-PnPProvisioningTemplate-PathListTemplate.xml