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 you want to avoid using. When you create a custom theme in SharePoint Online, it’s easy to add to your site. But what if you wish to remove it? By using PowerShell, it is possible to easily delete a custom theme and clean up your tenant. 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.
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 remove 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.
Conclusion
In Summary, deleting a custom theme in SharePoint Online using PowerShell is a relatively simple process that requires a few basic commands. It allows for cleaning up your SharePoint environment and removing unnecessary themes from the themes list. To delete a custom theme, you will need to connect to your SharePoint Online tenant using PowerShell, then you will need to use the Remove-SPOTheme or Remove-PnPTheme cmdlets to delete the theme. By following these steps, you should be able to successfully delete a custom theme using PowerShell. It’s important to note that before you delete any theme, make sure you have confirmed that it’s no longer needed or in use by any site.