SharePoint Online: Get List Templates using PowerShell
Requirement: Get List Templates in SharePoint Online using PowerShell.
How to Get List Templates in SharePoint Online?
List templates help you create a new list that is very similar to an existing list in your SharePoint Online. You can save an existing list as a template to help users get started quickly. This blog post will show you how to use PowerShell to get all the list templates available on your SharePoint Online site.
You can get list templates in SharePoint Online from:
- Site Settings >> “List templates” under “Web Designer Galleries.”
PowerShell to Get List Templates in SharePoint Online
If you need to get all the available list templates in SharePoint Online, use this PowerShell script. It gets all SharePoint Online list templates from the given site.
#Load SharePoint Online Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Custom Function to get all list templates from given site URL
Function Get-SPOListTemplates([String]$SiteURL)
{
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get All list templates
$ListTemplates=$Ctx.Web.ListTemplates
$Ctx.Load($ListTemplates)
$Ctx.ExecuteQuery()
#Get All Available list templates
$ListTemplates | Select Name, Description, ListTemplateTypeKind| Sort-Object Name | Format-Table -AutoSize
}
#Variable
$SiteURL="https://crescent.sharepoint.com"
#Call the function to get all list templates
Get-SPOListTemplates $SiteURL
This script retrieves all list templates from the given site collection:
Name | Description | Template ID |
---|---|---|
Announcements | A list of news items, statuses and other short bits of information. | 104 |
Asset Library | A place to share, browse and manage rich media assets, like image, audio and video files. | 851 |
Calendar | A calendar of upcoming meetings, deadlines or other events. Calendar information can be synchronized with Microsoft Outlook or other compatible programs. | 106 |
Contacts | A list of people your team works with, like customers or partners. Contacts lists can synchronize with Microsoft Outlook or other compatible programs. | 105 |
Converted Forms | List of user browser-enabled form templates on this site collection. | 10102 |
Custom List | Using a list gives you the power to share information the way you want with your team members. Create your own list from scratch, add any other columns you need, and add items individually, or bulk edit data with Quick Edit. | 100 |
Custom List in Datasheet View | A blank list which is displayed as a spreadsheet in order to allow easy data entry. You can add your own columns and views. This list type requires a compatible list datasheet ActiveX control, such as the one provided in Microsoft Office. | 120 |
Custom Workflow Process | Custom Workflow Process tracking list for this web. | 118 |
Data Connection Library | A place where you can easily share files that contain information about external data connections. | 130 |
Data Sources | Gallery for storing data source definitions | 110 |
Discussion Board | A place to have newsgroup-style discussions. Discussion boards make it easy to manage discussion threads and can be configured to require approval for all posts. | 108 |
Document Library | Use a document library to store, organize, sync, and share documents with people. You can use co-authoring, versioning, and check out to work on documents together. With your documents in one place, everybody can get the latest versions whenever they need them. You can also sync your documents to your local computer for offline access. | 101 |
External List | Create an external list to view the data in an External Content Type. | 600 |
Form Library | A place to manage business forms like status reports or purchase orders. Form libraries require a compatible XML editor, such as Microsoft InfoPath | 115 |
Issue Tracking | A list of issues or problems associated with a project or item. You can assign, prioritize and track issue status. | 1100 |
Links | A list of web pages or other resources. | 103 |
Maintenance Log Library Template | List Template that creates a document library for site collection maintenance logs | 175 |
No Code Public Workflows | Gallery for storing No Code Public Workflows | 122 |
No Code Workflows | Gallery for storing No Code Workflows | 117 |
Pages Library | A list template for creating Pages list in Publishing feature | 850 |
Persistent Storage List for MySite Published Feed | MySite MicroFeed Persistent Storage List | 544 |
Picture Library | A place to upload and share pictures. | 109 |
Project Tasks | A place for team or personal tasks. Project tasks lists provide a Gantt Chart view and can be opened by Microsoft Project or other compatible programs. | 150 |
Promoted Links | Use this list to display a set of link actions in a tile based visual layout. | 170 |
Report Library | A place where you can easily create and manage web pages and documents to track metrics, goals and business intelligence information. | 433 |
Status List | A place to track and display a set of goals. Colored icons display the degree to which the goals have been achieved. | 432 |
Survey | A list of questions which you would like to have people answer. Surveys allow you to quickly create questions and view graphical summaries of the responses. | 102 |
Tasks | A place for team or personal tasks. | 171 |
Tasks (2010) | A place for team or personal tasks. | 107 |
Wiki Page Library | An interconnected set of easily editable web pages, which can contain text, images and web parts. | 119 |
Workflow History | This list is used by SharePoint to store the history events for workflow instances. | 140 |
PowerShell to Get All Custom List Templates in SharePoint Online
We can get a list of available list templates by using this script:
#Custom Function to get all list templates from given site URL
Function Get-SPOCustomListTemplates([String]$SiteURL)
{
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get Custom list templates
$ListTemplates=$Ctx.site.GetCustomListTemplates($Ctx.site.RootWeb)
$Ctx.Load($ListTemplates)
$Ctx.ExecuteQuery()
#Get Custom list templates
$ListTemplates | Select Name, baseType, ListTemplateTypeKind | Format-Table -AutoSize
}
#Variable
$SiteURL="https://crescent.sharepoint.com"
#Call the function to get all list templates
Get-SPOCustomListTemplates $SiteURL
This script will return a list of all available custom list templates in SharePoint Online. Similarly, You can get a specific list template also:
#Custom Function to get all list templates from given site URL
Function Get-SPOCustomListTemplate([String]$SiteURL, [string]$ListTemplateName)
{
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get Custom list templates
$ListTemplates=$Ctx.site.GetCustomListTemplates($Ctx.site.RootWeb)
$Ctx.Load($ListTemplates)
$Ctx.ExecuteQuery()
#Filter Specific List Template
$ListTemplate = $ListTemplates | where { $_.Name -eq $ListTemplateName }
If($ListTemplate -ne $Null)
{
Return $ListTemplate
}
else
{
Write-host -f Yellow "List Template Not Found:"$ListTemplateName
}
}
#Variable
$SiteURL="https://crescent.sharepoint.com"
#Call the function to get specific list template
$Template = Get-SPOCustomListTemplate $SiteURL -ListTemplateName "Quick Links Template"
With the scripts provided in this article, you can quickly get a list of available list templates on the SharePoint Online site, filter them by name, and use them wherever required, like creating a new list from custom templates: How to Create List from Custom Template in SharePoint Online using PowerShell?