Hi I’m trying to update the theme of all sites under mysite host using this powershell script:
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({ foreach ($site in (Get-SPSite http://MYSITEHOST/personal/* -Limit ALL)) { [Microsoft.SharePoint.Utilities.SPTheme]::Open(“MySiteTheme”, $site.RootWeb.GetFile($site.RootWeb.ServerRelativeUrl + “/_catalogs/theme/15/Palette050.spcolor”))).ApplyTo($site.RootWeb, $true) } })
I am able to successfully update the theme to one of the out of the box themes and have changed it from blue to orange then to black. My issue is that I cannot use one of my own “palette.spcolor” files created in the colour palette tool. I get the following errors in powershell
Exception calling “ApplyTo” with “2” argument(s): “Object reference not set to an instance of an object.”
At line:1 char:145
+ [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({ foreach ($site in …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
The script runs fine with the palettes out the box, the issue is with those added to the /_catalogs/theme/15/…. The files are checked in – here is the original site reference – any ideas?
http://www.sharepointjohn.com/sharepoint-2013-powershell-set-theme-color-palette-sharepoint-site/Â
Many thanks,
Lee
I had the same problem. First I had to close all powershell sessions. Then opened the ISE again. Then I overwrote obe default palette, changed the script an it worked. Okay, there were error messages about the updateing process, but it worked.