Delete custom color themes from SharePoint
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.
# 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
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
Important changes coming to the way you login into PnP PowerShell (effective 9th September 2024) see Changes in PnP Management Shell registration in Microsoft 365
Contributors
Author(s) |
---|
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.