SharePoint Online: Remove a Custom Theme using PowerShell

Requirement: Remove a custom theme in SharePoint Online

If you’ve ever customized your SharePoint Online site by adding a custom theme, you may have later decided that you don’t like the look and feel of the theme. Or maybe someone else in your organization has created a custom theme that you don’t want to use anymore. When you create a custom theme in SharePoint Online, it’s easy to add it to your site. But what if you want to remove it? This guide will show you how to remove a custom theme from your SharePoint Online tenant. Let’s get started!

Open the Site Settings page by clicking the gear icon in the top-right corner of your screen and selecting Site Settings: then, under Look and Feel, click Themes. You’ll see a list of custom themes currently installed on your site.

sharepoint online remove custom theme powershell

Remove a Theme in SharePoint Online Using PowerShell:

We can remove a custom theme from the SharePoint Online tenant using the Remove-SPOTheme cmdlet. Keep in mind that once you removed a custom theme, it cannot be restored, so be sure that this is what you want to do before proceeding.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$ThemeName = "Corporate Theme"

#Connect-SPOService -Url $TenantAdminURL -Credential (Get-Credential)

#Get the custom theme to delete
$CustomTheme = Get-SPOTheme | Where {$_.Name -eq $ThemeName }
If($CustomTheme -ne $null)
{
    #Delete theme
    Remove-SPOTheme -Identity $ThemeName 
    Write-Host "Theme '$ThemeName' Removed Successfully!" -f Green
}
Else
{
    Write-Host "Theme '$ThemeName' doesn't exist!" -f Yellow
}

SharePoint Online: PowerShell to Delete a Theme

We can also use PnP PowerShell to remove a theme in SharePoint Online.

#Config Variables
$AdminSiteURL = "https://crescent-Admin.sharepoint.com"
$ThemeName = "Corporate Theme"

#Connect to PnP Online
Connect-PnPOnline -Url $AdminSiteURL -Interactive

#Get the Custom Theme
$Theme = Get-PnPTenantTheme | Where {$_.Name -eq $ThemeName}

If ($Theme.Count -eq 0) 
{ 
    Write-host "The specified Theme '$themeName' doesn't exist!" -ForegroundColor Yellow
    Break; 
}

#Remove the Theme
Remove-PnPTenantTheme -name $Theme.Name
Write-host "Custom Theme '$ThemeName' Removed Successfully!" -ForegroundColor Green

If you remove a custom theme, any site that uses the particular theme will not have any effect! They continue to use the colors of the deleted theme until you change it to a new theme.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply