Click here to Skip to main content
15,748,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I am trying to update the theme on the SharePoint site to Green. Company colors pretty close. Anyway, the code runs flawlessly. But borks the site badly.

I can get it back to what I need but I need this code to work. I have around 500 SharePoint sites to update and well this is just failing.

URL changed to protect the innocent (ME)

What it looks like after the elephant borkings. Rod: Borked SharePoint site? Anyone?[^]

<pre lang="text">
Code Example.

$tempC = new-object System.Net.WebClient
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext("")

#Get the Web
$Web = $Ctx.web

#Frame Master page URL
$MasterPageURL = "$($web.ServerRelativeUrl)/_catalogs/masterpage/seattle.master"

#Set Default Master page & Custom Master page
$web.CustomMasterUrl = $MasterPageURL
$Web.MasterUrl = $MasterPageURL

$fontSchemeUrl = "$($web.ServerRelativeUrl)/_catalogs/theme/15/fontscheme003.spfont"
$themeurl = "$($web.ServerRelativeUrl)/_catalogs/theme/15/Palette013.spcolor"
$imageUrl = "$($web.ServerRelativeUrl)/_layouts/15/images/siteIcon.png?rev=23"

$web.ApplyTheme($themeurl, $fontSchemeUrl, $imageUrl, $false)

What I have tried:

I have messed with the code alot. I have also tried Server side code on the SharePoint servers that pretty much do the same thing. Everything ends up looking like this.
Updated 10-Jul-18 5:50am
rnbergren 10-Jul-18 9:41am    
PS, I have googled extensively all the solutions I come across say the above code should work.

1 solution

#last few lines changed to this.

$nn = Out-Null

"applying theme"
$web.ApplyTheme($themeurl, $nn, $nn, $true);

#Works fine now.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900