CSOM + PowerShell: Setting Theme on Site


If you are looking to change the theme of your SharePoint 2013 and SharePoint Online site you can do this through CSOM.

Having connected to your environment you can run the below script that will change the theme to the Colour Palette to you have create – see this blog post on creating colour palettes

$web.ApplyTheme( “/_catalogs/theme/15/NewColourPalette.spcolor”, “/_catalogs/theme/15/NewFont.spfont”, “/_catalogs/theme/theme/15/BackGroundImage.jpg” , $True)


To see how to connect to your environment so the following blog post – Connecting to SharePoint Online through CSOM and PowerShell


CSOM of the Day: Introduction


Over the coming few weeks, I’m going to release some of the CSOM, SharePoint Online and PowerShell scripts that I use on a daily basis and use to deploy and configure our customers.  Any questions please do add them to the comments section and I’ll do my best to answer them.

I’ll also through in a few other PowerShell scripts that I use for SharePoint Online and hope you find them useful.

To make them easy to publish meaning I can do more and more and try and get them out as quickly as possible.  Here is a quick explanation of what to look out for in the script.

Add-Type –Path I:UsersAlexSkyDriveDeploymentbinMicrosoft.SharePoint.Client.dll
Add-Type –Path I:UsersAlexSkyDriveDeploymentbinMicrosoft.SharePoint.Client.Runtime.dll

This will import the 2 SharePoint DLLs required to complete commands and connect to Office 365.  Download them from the internet or get them from your SharePoint server.

We then need to connect to the environment giving a URL, username and password.

$username = “spadmin@bfcnetworks.onmicrosoft.com”
$password = Read-Host -Prompt “Enter password” -AsSecureString
$siteUrl = “https://bfcnetworks.sharepoint.com/”

When you run this script, you will get a pop out window asking for the password for the user you are connecting as.

We now connect using the URL, username and password using the DLLs.

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials

And to finish off, we load the SIte/Web.

$web = $ctx.Web

You will see this section a lot as it loads what we are asking for from SharePoint

Each post will include this but this post will be used as a guide.

I personally like to use the Windows PowerShell ISE so give it a go yourselves.