Get And Apply PnP Template Of A Specific List Or Library Using PnP Provisioning Engine

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  
$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 }  
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 – Apply-PnPProvisioningTemplate-PathListTemplate.xml

This solution is brought to you by our SharePoint professionals.

Softree Technology employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.

Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best


Add Your Comments

Your email address will not be published. Required fields are marked *