Delete custom SharePoint list designs
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.
Warning
Please be aware this script contains a command that will remove or delete an artifact, ensure you test and understand the implications of running the script.
$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
}
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
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.