Skip to main content

SharePoint 2013 - Creating and Applying Composed Looks (PowerShell)

If you are a SharePoint administrator looking to quickly apply some basic branding to a site-collection in your SharePoint 2013 environment then you've come to the right spot.

Before we begin I assume you have a basic understanding of what Composed Looks are, and perhaps you spent some time playing around with this concept in SharePoint 2013.

If not, then don't worry.  Here is a basic primer:
  • Composed Look is basically a package which contains elements used for controlling the overall look and feel of a SharePoint site.  This includes but not limited to Colors, Fonts, Background Image, CSS files, and Master Page files.
  • Once created, Composed Look can be packaged by using the Design Manager feature, or we can use PowerShell to apply it across one or multiple site collections.
NOTE: In this post we will be focusing on creating a composed look from an .spcolor file then using PowerShell to apply the design to a site-site collection of our choice.  We will not be demonstrating steps on how to apply design using Design Manager.

Step 1: Create a Composed Look (.spcolor file)

There are a couple of different ways we can approach this, but to make everyone's life a whole lot easier I recommend that you download and install a free SharePoint Color Palette Tool from Microsoft.  Trust me, it will save you a ton of time.
  1. Open the SharePoint Color Palette Tool.
  2. Use the Color Slots pane to specify hex values for each color bucket.  You can also expand each color bucket to further customize the colors.  To better understand what page element each color bucket represents please refer to the following article: Color palettes and fonts in SharePoint 2013
  3. Changes made in the Color Slots pane will automatically appear in the Preview pane.
  4. When finished, save the .spcolor file to a desired location.  I named my file customPalette.spcolor.

Step 2:  Apply Color Palette using PowerShell

From this point forward we can relay on a simple PowerShell script to do the rest of the work for us.  Keep in mind that the following script will apply changes to all SPWeb objects (sub-sites) within the designated site collections.

$siteCollectionUrl = $args[0]
$spSite = Get-SPSite $siteCollectionUrl
$spWeb = $spSite.RootWeb
$spFolder = $spWeb.GetFolder("_catalogs/theme/15")
$spFileCollection = $spFolder.Files
$file = Get-ChildItem "customPalette.spcolor"
$themeUrl = "_catalogs/theme/15/customPalette.spcolor"
$spFile = $spFileCollection.Add($themeUrl,$file.OpenRead(),$true)
$theme = [Microsoft.SharePoint.Utilities.SPTheme]::Open("Current", $spFile)
$spSite.AllWebs | % { Write-Host $_.Url; $theme.ApplyTo($_, $true);}

Make sure to save the above code as a .ps1 file.  I named my file applydesign.ps1 and saved it to the same location as customPalette.spcolor file.

Now that we have a Color Palette (.spcolor) file from Step 1 and our PS script we are ready to execute:

  1. Open SharePoint 2013 Management Shell on one of the SharePoint server in the farm (HINT: Run as Administrator).
  2. Using the shell, navigate to the directory where the two files above are located.
  3. Run the PowerShell script with a single parameter which is the URL of the site-collection where you wish to apply changes.
.\applydesign.ps1 http://site_collection_URL

The script executes, places the custom Color Palette inside the Theme Gallery (/_catalogs/theme/15) and applies the changes using the "Current" composed look as a shell.  This is what the finished product looks like.
If you need further clarification of the script and how it works please leave a comment and I'll do my best to assist.
Thanks for reading!

Comments

  1. Can i use the same script for SharePoint Online Site Collection ?

    ReplyDelete
    Replies
    1. Hello Viral. The script in this post will not work using SharePoint Online Management Shell. If you are sticking to Composed Looks in SharePoint Online, you can leverage Design Manager and create a design package that way. Once you have a design package created, you can distribute it to other site collections. Keep in mind, you have to activate SharePoint Server Publishing Infrastructure feature for the Design Manager to appear in Site Settings.
      Thanks!

      Delete

Post a Comment

Popular posts from this blog

SharePoint Server Search - Error Starting

Problem I recently ran into this snag at a client site while setting up the Search Service Application.  I was able to create the service application without a problem however when I attempted to start the SharePoint Server Search service (Manage services on server page) I kept getting Error Starting . After taking a peak at the logs I found the following: An attempt to start/stop instance of service SharePoint Server Search on server did not succeed. Re-run the action via UI or command line on the specified server. Additional information is below. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) I double/triple checked the permissions and made sure that my Farm Administrator account was a member of WSS_WPG and WSS_ADMIN_WPG groups, and that those groups had full control permissions to the C:\Windows\Tasks and C:\Windows\Temp folders. Resolution I nearly lost hope when I remembered my old lost friend called STSADM.EXE. Just like in the old days,

SharePoint 2013 - Can't access the site externally in Internet Explorer ("Page cannot be displayed")

Synopsis Before we start talking about the problem let's understand the setup here.  We have a SharePoint 2013 intranet site that is also configured for access outside of the corporate network.  Employees use the same URL to visit the site both internally and externally via standard ports (80 and 443). Internal URL: http://sharepoint.domain.com Public URL: https://sharepoint.domain.com The site URL has been added to the Local Intranet zone in Internet Explorer for passing domain credentials. Alternate Access Mappings have been configured in such a way that if a user requests the site over HTTP they are automatically re-directed to HTTPS. Internal URL Zone Public URL for Zone https://sharepoint.domain.com Default https://sharepoint.domain.com http://sharepoint.domain.com Default https://sharepoint.domain.com Web application has been configured to use Kerberos protocol for authenticating incoming c