SharePoint Online: How to Delete a List Template using PowerShell?

Requirement: Delete list template in SharePoint Online

How to delete a list template SharePoint Online?

To remove a list template in SharePoint Online, do the following:

  • Login to your SharePoint Online site collection (List templates are scoped at site collection level) >> Click on Settings >> Site Settings
  • On the Site Settings page, click on “List Templates” under Web Designer Galleries (
  • Select the list template to delete and click on “Delete Document” from the ribbon
  • Confirm the prompt to delete the custom list template in SharePoint Online.
    sharepoint online delete list template

SharePoint Online: PowerShell to Delete List Template

#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"
#Variables for Processing
$SiteUrl = ""
$ListTemplateInternalName= "Project Tasks.stp"

#Get Credentials to connect
$Cred= Get-Credential
Try {    
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
    #Get the Web
    $Web = $Ctx.Web
    #Get the List Template
    $ListTemplateFile = $Web.GetFileByURL("_catalogs/lt/" + $ListTemplateInternalName)

    If($ListTemplateFile -ne $Null)
        Write-host -f Green "List Template Deleted Successfully!"
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

PnP PowerShell to Delete a List Template in SharePoint Online:

$SiteURL = ""
$ListTemplateInternalName= "IC Documents.stp"

#Connect to the Site
Connect-PnPOnline -URL $SiteURL -Interactive

#Get the List Template
$TemplateFile = Get-PnPFolderItem -FolderSiteRelativeUrl "_catalogs/lt" -ItemName $ListTemplateInternalName

If ($TemplateFile -ne $null)
    #Delete the List Template
    Remove-PnPFile -SiteRelativeUrl ("/_catalogs/lt/"+$ListTemplateInternalName) -Recycle -Force
    Write-host -f Green "List Template Deleted Successfully!"
    Write-host -f Yellow "Template Not Found!"

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply