How to add Custom Theme in SharePoint using PowerShell

In this article let’s discuss how to add customized theme in SharePoint Online using PowerShell.

Customizations in SharePoint online is quite easy in recent days. Applying custom theme in SharePoint Online sites to support the branding of an organization is a much-needed feature. Here we are going to see how you can achieve it using the PowerShell.

Below are the prerequisites to implement custom theme

  • You must be a tenant administrator.
  • Install the SharePoint Online Management Shell
  • Theme color you would like to apply

Install SharePoint Online Management PowerShell:

Download and install the SharePoint Online Management Shell using the following PowerShell command.

install SharePoint Online

Or you can also this link to download the SharePoint Online Management PowerShell

Connect to SharePoint Online:

Connect to SharePoint Online using the Connect-SPOService cmdlet which requires two parameters namely

  • URL – SharePoint admin site URL
  • Credentials – Credentials of the SharePoint Online Administrator, which is derived using the Get-Credential cmdlet

Refer the below code snippet:

Connect SP Online

Get the user credentials by using the Get-Credential cmdlet, which prompts for username and password like below,

Get Credentials

Add Custom Theme:

After connecting to SharePoint Online, it’s time to generate the custom theme for the SharePoint site. The generation of custom theme follows two steps namely generation of theme palette and adding the custom theme using generated palette.

First, Go to the Microsoft Fluent UI Theme Designer, where you can find an option in the left to change the primary color, text color, and the background color of the site.

Theme Generator

After modifying the colors, choose the Export Theme option on the top right corner.

It shows the code block which has been generated using the configured color themes. In that, choose PowerShell and copy the code block.

Theme Palette

Now go back to the PowerShell and add the below command.

Add Theme

Replace the copied code block from the Fluent UI Theme Designer to the $themepalette variable.

 Add-SPOTheme cmdlet requires three parameters namely,

  • Identity – specified the theme name
  • Palette – specifies color palettes in the theme, which will be derived using the $themepalette variable
  • IsInverted – specifies whether the theme is inverted or not

Run the script.

Apply the New Look:

Connect to the SharePoint site with the targeted tenant and go to the settings icon in the top Office 365 bar, where you can see the “Change the look” option like below,

Change the look

Click that option and select Theme, the generated theme will appear in the window with the name ‘Custom theme’, select the same and click Save.

Apply Theme

Now check the SharePoint page for which you have applied the theme.

Sharing is Caring!

Leave a Reply

Your email address will not be published. Required fields are marked *