0

I created/added a Theme in SharePoint online using following commands. And provided all the details/parameters.

Connect-PnPOnline –Url $adminSiteUrl –Credentials (Get-Credential)
Add-PnPTenantTheme -Identity $themeName -Palette $palette -IsInverted $false

Theme is added successfully and I can select this new theme from change the look option.

But now I want to delete this theme. But I cannot find any option to delete it.

I also tried Remove-PnPTenantTheme but I am getting following error.

Remove-PnPTenantTheme : Unknown Error At line:1 char:1 + Remove-PnPTenantTheme -Identity "BASF_Orange" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Remove-PnPTenantTheme], ServerException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Admin.RemoveTenantTheme

Can anyone please guide me on how to delete this theme.

THanks.

1

You can try with the -name parameter than -identity parameter.

Example:

Remove-PnPTenantTheme -name $theme.Name

Or

You can try out the below code:

Inside the foreach loop, add if condition to check your theme - it will ensure that your custom theme is readable through the PnP command then inside that same if perform the "Remove-PnPTenantTheme -name $theme.Name"

$adminUrl= "https://mytenant-admin.sharepoint.com"
$sparksjoy = "Cat Lovers United", "Multicolored theme"
Connect-PnPOnline -Url $adminUrl -UseWebLogin
$themes = Get-PnPTenantTheme | where {-not ($sparksjoy -contains $_.Name)}
$themes | Format-Table Name
if ($themes.Count -eq 0) { break }
Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $themes.Count
foreach ($theme in $themes)
{
   if ($theme.Name -eq "Your theme name which you want to delete")
   {
    $progress++
    write-host $progress / $total":" $theme.Name
    Remove-PnPTenantTheme -name $theme.Name
   }
}

Source:

DOES IT SPARK JOY? POWERSHELL SCRIPTS FOR KEEPING YOUR DEVELOPMENT ENVIRONMENT TIDY AND SPOTLESS

1
  • Hi Habibur thanks for the reply. But I already tried this code also I tried both Name and Identity. But it didn't work. – Rohit Waghela Apr 13 '20 at 15:29
1

Use the following command to delete the custom theme:

Remove-SPOTheme -Name "Custom Theme Name"

Reference:

https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/remove-spotheme?view=sharepoint-ps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.