Create SharePoint custom list templates with PowerShell

As a global or SharePoint admin in Microsoft 365, you can provide custom list templates for users in your organization. When users create new lists, they can select from these templates alongside the built-in templates from Microsoft. This enables your organization to create repeatable list solutions (in SharePoint, Teams, and within the Lists app itself).

You can create and manage custom list templates using Microsoft PowerShell:

  1. If you haven’t already got it installed, download SharePoint Online Management Shell.
  2. Connect to SharePoint as a global admin or SharePoint admin in Microsoft 365.

Add a custom template

Follow these steps to create a custom list template.

  1. Run the following command to extract the site script output from an existing list and write it to a variable:
Copy$extracted = Get-SPOSiteScriptFromList -ListUrl "https://contoso.sharepoint.com/sites/strategy/customer-contacts"

2. Reference the variable in the following command to upload a site script that can be used with a list design.

Add-SPOSiteScript -Title "Contoso Customer Tracker" -Description "This creates a customer contact list" -Content $extracted

Create your list design using the site script ID returned from the step above:

PowerShellCopyAdd-SPOListDesign -Title "Contoso customer tracking" -Description "Tracks key customer data in a list" -SiteScripts "<ID from previous step>" -ListColor Orange -ListIcon BullseyeTarget -Thumbnail "https://contoso.sharepoint.com/SiteAssets/site-thumbnail.png"

When users in your organization create a list (in SharePoint, Teams, or the Lists app), they’ll see the template on the “From your organization” tab.

The "Contoso customer tracking" template on the "From your organization" tab of the Create a list dialog box.

 Note

List templates can’t be updated after you add them. Instead, remove the existing template and add the updated version.

Scope the permissions to a custom template

By default, the custom list template will be available to everyone in your organization. If you want, you can limit access to specific users or a security group. The following example shows how to grant an individual user view rights to a template.

PowerShell cmdlet

Grant-SPOSiteDesignRights 
  -Identity <List design ID to apply rights to> 
  -Principals "you@yourtenant.onmicrosoft.com" 
  -Rights View 

Get template(s)

The following example retrieves all custom list templates.

PowerShellCopy

Get-SPOListDesign <List design ID> 

Remove a custom template

The following example shows how to remove a custom list template so that it’s no longer available to users when they create lists.

PowerShellCopy

Remove-SPOListDesign <List design ID> 

You can also remove the associated site scripts that the list design is referencing using:

PowerShellCopy

Remove-SPOSiteScript <Site script ID> 

Categories:

No Responses

Leave a Reply

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