Configure

Delete custom color themes from SharePoint

Creating a lot of beautiful themes lately and testing them but don't want to keep them anymore, this script is for you

Summary

Have you been creating a lot of beautiful themes lately and testing them in your dev tenant, but don't want to keep them anymore? If yes, then this PowerShell script is for you.

powershell

# SharePoint online admin center URL
$SPOAdmminSite = "https://contoso-admin.sharepoint.com"

$themesToKeep = "Contoso Explorers", "Multicolored theme"

# Connect to SharePoint online admin center
Connect-PnPOnline -Url $SPOAdmminSite -Interactive

# Get all themes from the current tenant
$themes = Get-PnPTenantTheme

$themes = $themes | where {-not ($themesToKeep -contains $_.name)}
$themes | Format-Table name

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

Read-Host -Prompt "Press Enter to start deleting $($themes.Count) themes (CTRL + C to exit)"
$progress = 0
$total = $themes.Count

foreach ($theme in $themes)
{
  $progress++
  write-host $progress / $total":" $theme.name
  
  # Delete custom color themes from SharePoint
  Remove-PnPTenantTheme -Identity "$($theme.name)"
}

# Disconnect SharePoint online connection
Disconnect-PnPOnline

Contributors

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