Delete custom SharePoint list designs
Remove List designs and corresponding site scripts.
Summary
Custom list templates can be deleted by removing the list designs and associated site scripts when no longer needed. Use the scripts below to delete them.
$adminSiteUrl = "https://contoso-admin.sharepoint.com/"
Connect-PnPOnline -url $adminSiteUrl -Interactive
$listDesignsTokeep = "Test Document Library", "List To Keep"
$listDesigns = Get-PnPListDesign | Where-Object { -not ($listDesignsTokeep -contains $_.Title)}
if ($listDesigns.Count -eq 0) { break }
$listDesigns | Format-Table Title, SiteScriptIds, Description
Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $listDesigns.Count
foreach ($listDesign in $listDesigns)
{
$progress++
Write-Host $progress / $total":" $listDesign.Title
$siteScriptId = $listDesign | select SiteScriptIds
$siteScript = Get-PnPSiteScript -Identity $siteScriptId.SiteScriptIds.Guid
Remove-PnPListDesign -Identity $listDesign -Force
Remove-PnPSiteScript -Identity $siteScript -Force
}
Contributors
| Author(s) |
|---|
| Reshmee Auckloo |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
Tool documentation & references
- PnP PowerShell to manage list designs and create lists/libraries using list designs
Refers to the article for other PnP PowerShell cmdlets