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.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.SharePointOnlineCredentials")
$tempC = new-object System.Net.WebClient
$tempC.UseDefaultCredentials=$true
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext("http://bergren.net/")
$Ctx.Credentials=$tempC.Credentials
#Get the Web
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Frame Master page URL
$MasterPageURL = "$($web.ServerRelativeUrl)/_catalogs/masterpage/seattle.master"
#Set Default Master page & Custom Master page
$web.CustomMasterUrl = $MasterPageURL
$Web.MasterUrl = $MasterPageURL
$web.Update()
$Ctx.ExecuteQuery()
$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)
$web.Update()
$Ctx.ExecuteQuery()
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.