Configure

Delete custom SharePoint site designs

Remove Site designs and site scripts that ends up just hanging around in your tenant. Use the scripts below to get rid of them

Summary

Site designs and especially site scripts can be something that ends up just hanging around in your tenant for a long time even though you no longer need them for anything. Use the scripts below to get rid of them. You might also find some site scripts that are not linked to any site design and hence never get executed!

powershell
Connect-SPOService "https://contoso-admin.sharepoint.com"

$keepThese = "Register the new site", "Corporate Basic Site", "Corporate Internal Site"
$siteDesigns = Get-SPOSiteDesign
$siteDesigns = $siteDesigns | Where-Object { -not ($keepThese -contains $_.Title)}

if ($siteDesigns.Count -eq 0) { break }

$siteDesigns | Format-Table Title, SiteScriptIds, Description
Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $siteDesigns.Count

foreach ($siteDesign in $siteDesigns)
{
  $progress++
  Write-Host $progress / $total":" $siteDesign.Title
  Remove-SPOSiteDesign $siteDesign.Id
}

Contributors

Author(s)
Paul Bullock
Leon Armston
Ganesh Sanap

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

Keep exploring