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 2013 - Simple Glossary using "HTML Form Web Part"

Introduction At some point you probably thought about incorporating glossary functionality as a part of a larger solution, or perhaps you were simply looking for providing a more intuitive way of filtering hundreds of items within a List or Library. Now there are countless web parts out there that you can either purchase or download from the SharePoint Store free of charge, and they all come with their own set of bells and whistles.  However, if you are looking at building one yourself, well look no further. To accomplish this we will need three major ingredients: SharePoint Page (either Wiki or Publishing will work) SharePoint List/Library with some content (Files/Items) HTML Form Web Part Let's Implement In this post I’m using a simple Wiki page, but you can also use a Publishing page as well.  We just need a canvas to display our glossary. I presume you already have a list or library that contains some content which is applicable to this concept.  I’m

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

Remove Orphaned Web Parts - MissingWebPart

At some point you may have encountered an error like this while browsing through the SharePoint Health Analyzer or if you are attempting to test your content database (i.e., Test-SPContentDatabase) prior to mounting it. Message reads something like this: One caveat is that the log message never reveals the Location of the culprit web part.  Luckily we can utilize T-SQL to query the content database and reveal the location of the web part in question.   Query the Content Database To do this fire up the SQL Server Management Studio either locally from your machine or while logged on to the SQL Server back-end of your SharePoint farm, open up the new Query window and enter the following statement: USE < Content_Database_Name > SELECT AllDocs.SiteId,WebId, Webs.Title as 'Web Title', ListId, DirName,LeafName  FROM AllDocs    inner join AllWebParts on Alldocs.Id = AllWebParts.tp_PageUrlID  inner join Webs on Alldocs.WebId = webs.Id  WHERE AllWebParts.tp