How to export SharePoint List Template using PnP PowerShell?


I occasionally need to duplicate SharePoint List Definition from one site to other or some time create a new list from the existing list.

PnP.PowerShell can rescue using the Template methods.




Using the Get-PnPSiteTemplate you can the template definition in the XML. Using the Save-PnPsitetemplate you can save the template definition into the local file system.

Using the Invoke-PnPSiteTemplate you can use the local file system template definition file to a brand new site or same site with new list.

Step By Step

#1 Install Pnp.PowerShell Power Shell Module. Refer this article.

#2 Using the SharePoint App register pages register an app. Refer this article.

#3 Execute the following script block.

$HashArgs = @{
    url = "https://{YOUR TENANT}{YOUR SITE}"
    ClientId = "{ID FROM STEP #2}"
    ClientSecret = "{SECRET FROM STEP # 2}"

$conn = Connect-pnpOnline @HashArgs -ReturnConnection

# The script below will help you to get a template of a specific list or library.
$listTitle = Read-Host "Enter title of the list or library"  
$outputTemplateFile = $("{0}ListTemplate.xml" -f  $listTitle)
$template = Get-PnPSiteTemplate -OutputInstance -Handlers Lists  
$listTemplate = $template.Lists | Where-Object { $_.Title -eq $listTitle }  
Save-PnPSiteTemplate -InputInstance $template -Out $outputTemplateFile


Using the above method you can save template for a specific list and using Invoke-PnPSiteTemplate create the same list again.

About Pankaj

I am a Developer and my linked profile is
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s