SharePoint 2013 includes a pretty useful theming engine that is light years ahead of previous versions of SharePoint. There is one caveat that is a bit annoying: you cannot apply the themes to certain types of sites through the web interface. For instance, you cannot set the theme color of the My Site host.

However, you can do this programmatically and through PowerShell. This example shows how to set the SharePoint theme palette for the My Site host:

[powershell]$web = Get-SPWeb http://site/my
$file = $web.GetFile($web.ServerRelativeUrl + “/_catalogs/theme/15/Palette015.spcolor”)
$theme = [Microsoft.SharePoint.Utilities.SPTheme]::Open(“MySiteTheme”, $file)
$theme.ApplyTo($web, $false)[/powershell]

Notes about this example:

  • “http://site/my” is the URL to the SharePoint site (SPWeb) that we are setting the theme for.

  • “/_catalogs/theme/15/Palette015.spcolor” is the color palette that is already on the site. You can add your own color palettes as well.

  • “MySiteTheme” is the name this generated theme takes on. You can put just about anything here.

  • On the $theme.ApplyTo method, the second parameter indicates whether or not this theme should propagate to each subsite. In this example, it is set to $false.

This script could be applied to sites that you cannot access this setting through the web interface or could even be applied to batches of sites. For instance, you could do a foreach statement to apply this to each SPWeb in a site collection.

Hopefully you find this useful.


Here is an example of using this to update the theme applied to each users personal site (My Content / SkyDrive):

[powershell][Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({ foreach ($site in (Get-SPSite http://site/my/personal/* -Limit ALL)) { ([Microsoft.SharePoint.Utilities.SPTheme]::Open(“MySiteTheme”, $site.RootWeb.GetFile($site.RootWeb.ServerRelativeUrl + “/_catalogs/theme/15/Palette015.spcolor”))).ApplyTo($site.RootWeb, $true) } })[/powershell]

Pin It on Pinterest

Share This
%d bloggers like this: