I want to apply one of the default themes to my SharePoint site. I found Web.ApplyTheme() method which requires

  • string colorPaletteUrl,
  • string fontSchemeUrl,
  • string backgroundImageUrl,
  • bool shareGenerated

I have tried to use one of the existing colorPalettes and fontSchemes found under Designer Gallery: enter image description here

$ctx.Web.ApplyTheme("https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/Palette001","https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/fontscheme001.spfont",$null, $true)

and url with .spcolor extension:

$ctx.Web.ApplyTheme("https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/Palette001","https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/fontscheme001.spfont",$null, $true)

but I am receiving an error

Exception calling "ApplyTheme" with "4" argument(s): "The 'colorPaletteUrl' argument is invalid."

How can I assign a theme to a SharePoint Online site?


2 Answers 2


If you notice in both of your given code examples the Palette001 is without .spcolor extension. I suspect this could be the issue.

Refer screen shot which show Palatte001 with extension.

enter image description here

I have not tested this code but you can try using below improvements

Improving your code with added .spcolor extension:

$ctx.Web.ApplyTheme("https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/Palette001.spcolor","https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/fontscheme001.spfont",$null, $true)

Now if we consider $null argument as mentioned by @Anuja, we can improve further.

$bgImageUrl = Out-Null
$ctx.Web.ApplyTheme("https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/Palette001.spcolor", "https://tenant.sharepoint.com/sites/powie1/_catalogs/theme/15/fontscheme001.spfont", $bgImageUrl, $true)

Lastly referring from CSOM + PowerShell: Setting Theme on Site, the urls are relative here.

$web.ApplyTheme( "/_catalogs/theme/15/Palette001.spcolor", "/_catalogs/theme/15/fontscheme001.spfont", $bgImageUrl, $true)

Try with Out-Null instead of $null or null or Empty String

follow this link for more information http://sprider.org/2015/03/24/o365-sharepoint-online-apply-theme-csom-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.