SharePoint Online: Remove a Custom Theme using PowerShell

Requirement: Remove a custom theme in SharePoint Online.

sharepoint online remove custom theme powershell

Remove a Theme in SharePoint Online Using PowerShell:

We can remove a custom theme from SharePoint Online tenant using Remove-SPOTheme cmdlet

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

$TenantAdminURL = ""
$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
    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 = ""
$ThemeName = "Corporate Theme"

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

#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

#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 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