How to save a Microsoft Lists personal lists as a template

Microsoft Lists has introduced the concept of personal lists that are stored in the user my site and are only visible to the user.

In this article I’ll explain you step by step how you can use an existent personal list to create a template that you can later reuse to create new lists.

Microsoft Lists template

Despite being stored in the personal site collection and being accessed through the Microsoft Lists app, personal lists continue to be stored in SharePoint which means that we can take advantage of all the good features that PnP PowerShell has to offer.

Before we get started you need to make sure you have PnP PowerShell installed on your machine, if you don’t instructions on how to install it are availablehere.

Save a personal list as a template

To save a personal list as a template you will need the name of the list and the URL to your personal site. The URL for your personal site has the following format:

https://contoso-my.sharepoint.com/personal/joao_contoso_com

If you don’t know the URL to your site, you can copy it from the URL as highlighted in the image.

Now that you have everything you need it’s time to create your personal list template.

  1. Download and extract the PowerShell files from here, or alternatively copy this code and save it in a ps1 file
    Write-Host "Type your personal site URL"
    $siteURL = Read-Host
    Write-Host "Type the name of the List"
    $listName = Read-Host
    $templateName = $listName 
    Write-Host "Do you want to include the existent content in the template? Y/N"		
    $option = Read-Host
    
    $path = [regex]::Replace($MyInvocation.MyCommand.Definition, "\\saveListTemplate.ps1", "")
    cd $path
    
    Connect-PnPOnline -Url $siteURL
    Get-PnPProvisioningTemplate -Handlers Lists -ListsToExtract $listName -Out ("{0}.xml" -f $templateName)
    
    if($option.toLower() -eq "y"){
    	Add-PnPDataRowsToProvisioningTemplate -path ("{0}.xml" -f $templateName) -List $listName -Query ''
    }
  2. Right click on the saveListTemplate.ps1 and select Run with PowerShell
  3. Fill the form by providing:
    • The personal site URL
    • The list name
    • Chose if you want to include any existent content in the template
    • Provide your login credentials

    Microsoft Lists template

  4. Wait for the script execution and you will end up with an XML template file next to your PowerShell file with the same name of the list

Create a personal list from template

Once you get the XML template file of your personal list you are ready to recreate it repeatedly, all you have to do is:

  1. Go to the folder where you have your template and your PowerShell files
  2. Right click on applyListTemplate.ps1 and select Run with PowerShell, alternatively you can copy the code below
    Write-Host "Type your personal site URL"
    $siteURL = Read-Host
    Write-Host "What is your template name?"
    $templateName = Read-Host
    Write-Host "Type the name for your new List"
    $listName = Read-Host
    
    
    $path = [regex]::Replace($MyInvocation.MyCommand.Definition, "\\applyListTemplate.ps1", "")
    cd $path
    
    ((Get-Content -path (".\{0}.xml" -f $templateName) -Raw) -replace $templateName, $listName) | Set-Content -Path (".\{0}.xml" -f $listName)
    
    Connect-PnPOnline -Url $siteURL
    
    Apply-PnPProvisioningTemplate -Path ("{0}.xml" -f $listName)
    
    Remove-Item -Path (".\{0}.xml" -f $listName)
  3. Fill the form by providing
    • The personal site URL
    • The name of your template
    • The name for your new list

    Microsoft Lists template

  4. Provide your login credentials
  5. Wait for the script execution and you will have your new list created from a template ready to be used.

Microsoft Lists template

Conclusion

Despite providing a template feature Microsoft Lists is still in its early steps and does not provide the UI to include your own templates in the system. Using the scripts provided in this article you will be able to create templates of your personal lists but also from any other list in your SharePoint or Microsoft Lists environment.

Download Scripts


No comments yet

Leave a Reply


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.