PowerShell Script to Remove Theme from Sub Sites

I had a requirement to apply a custom css file to a SharePoint collection on which there was a custom composed look with background image applied.

I used the composed look option to reset the theme to a default without background image on the main site collection URL. Unfortunately sub sites were still displaying the background image.

I tried setting the theme of the Sub Site using function ApplyTo or ApplyTheme without luck.

I finally decided to remove theme from the sub sites which works the same way as resetting to default.

The PowerShell script to remove theme from sub sites is

$url = “http://inm.test/local
$site = Get-SPSite -Identity $url
 foreach ($web in $site.AllWebs) {
  Write-Host “Web Title: ” $web.Title
   $web.allowunsafeupdates = $true
  $theme = [Microsoft.SharePoint.Utilities.ThmxTheme]::RemoveThemeFromWeb($web,$false)
  $web.allowunsafeupdates = $false

The background image on all sub sites is cleared.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s