Changing a SharePoint site Theme using PowerShell

This blog article describes how you can use PowerShell to change the look (theme) of an existing SharePoint site. In order for us to be able to do this, we will need to begin by getting a reference to the SharePoint 2013 Design Catalog. You can obtain this by calling the following line of PowerShell.

$designCatalog = $siteCollection.GetCatalog(“Design”)

Next, we need to decide on what theme to apply. To assist you in choosing what theme to apply, you could use the following PowerShell command to list all existing themes in your SharePoint 2013 environment.

$designCatalog.Items | Format-Table Name

Figure 1 below shows the result of running this command on a plain installation of SharePoint Server 2013 SP1.

ListThemes.png

Figure 1 – Listing all existing SharePoint 2013 Themes on a site collection using PowerShell

We’re almost there. Now that you have obtained a list of all existing themes, you need to get a reference to the ne you wish to use. In our case, we will be using the “Characters” theme for demo purposes. This “theme object”, is nothing more than an SPListItem object exposing various properties that help describe the theme n question. In order for you to apply a theme, you will need to get the properties of this theme object and ass them on to the ApplyTheme method of the site you wish to modify. The following example will take a reference to the root web and apply the characters theme on it using PowerShell.

$theme = $designCatalog.Items | Where{$_.Name -eq “Characters”}

$rootWeb = Get-SPWeb http://localhost

$rootWeb.ApplyTheme($theme[“ThemeUrl”].Split(‘,’)[1].Trim(), $null, $theme[“ImageUrl”].Split(‘,’)[1].Trim(), $true) 

Figure 2 below shows the resulting theme applied on the specified web.

CharactersThemeusingPowerShell.png

Figure 2 – SharePoint web with custom theme using PowerShell

Microsoft Premier Field Engineer – SharePoint

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*