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 da...

SharePoint Virtual Summit 2017 - What's new for SharePoint and OneDrive?

Recently, during the SharePoint Virtual Summit, Microsoft unveiled yet another roadmap for SharePoint and OneDrive.  If you haven't had a chance to join you can view the recording  here . The most exciting part of all of this is that we won't have to wait long to see these new capabilities become a part of our SharePoint ecosystem.  Most of the features announced are geared towards SharePoint Online and OneDrive in Office 365, which emphasizes Microsoft's strong push to the cloud. There are more than 250,000 organizations and over 85% of Fortune 500 companies that have SharePoint as a part of their Office 365 tenant. Just in the last year, SharePoint usage has grown 90%, content stored has grown 300% and more than 10 million new SharePoint sites have been created. More than 60% of SharePoint licensed seats are now online, reflecting the value customers see with SharePoint in Office 365. So, let's take a look at what Microsoft has coming down the pipe. OneDriv...

SharePoint 2013 - Start a Site Workflow using a Custom Action

In recent travels I've encountered what seems to be either a product limitation or a bug. After digging around some it appeared that I wasn't the only one facing this challenge, and unfortunately there wasn't a concrete enough solution or workaround out there. Hence the blog post hoping to save some of you the unnecessary hair-pulling which I had to endure. My task was fairly simple; "Start a Site Workflow using a Custom Action button". The first part, creating a Custom Action, is trivial. This can be done in Visual Studio or SharePoint Designer. For the sake of simplicity I used SharePoint Designer. Create a Custom Action button Start up SharePoint Designer 2013 and connect to the desired site. From the left navigation select Lists and Libraries. I'm using a simple list called "List One". Boring name, but easy to follow. :) Click on the list name to manage list settings. From the ribbon select Custom Action button then click View Ribb...