-1

I need to create 100+ site collections in SP2013. I have a PowerShell script and XML file to achieve this (and is working).

However, marketing want to brand and change the look of the Team Sites - I'm just going to use the 'Grey' composed look for now.

(Ultimately I would like to include theme/logo/look change in initial site collection script) But for now I'm hoping someone can shed light on the error described.

The script I have to do this (i.e. it changes composed look retrospectively)

doesn't work - Exception Calling "ApplyTheme" with "4" arguments(s): "The Web application at http://_catalogs/theme/15/Palette032.spcolor could not be found. Verify...."

The http address is clearly incorrect but I am using ServerRelativeURL? The spcolor http://xxx.xxxxx.org.uk/_catalogs/theme/15/Palette032.spcolor file exists

The script is:

$themeName = "Grey"

$SPSite = Get-SPSite "http://xxx.xxxxx.org.uk" 

foreach ($SPWeb in $SPSite.AllWebs) 

{
  $SPWeb.allowunsafeupdates = $true

  $fontSchemeUrl = $SPWeb.ServerRelativeUrl + ""

  $themeurl = $SPWeb.ServerRelativeUrl + "/_catalogs/theme/15/Palette032.spcolor"

  $imageUrl = $SPWeb.ServerRelativeUrl + ""

  **$SPWeb.ApplyTheme($themeUrl, $fontSchemeUrl, $imageUrl, $false);**

  Write-Host "Set" $themeName "at :" $SPWeb.Title "(" $SPWeb.Url ")" 

  $SPWeb.Update()

  $SPWeb.allowunsafeupdates = $false

  $SPWeb.Dispose()

}  
$SPSite.Dispose()

What am I missing? Any help is greatly appreciated.

0

ApplyTheme "prefers" absolute urls, so you need to replace ServerRelativeUrl with Url. Code will look like this:

$themeName = "Grey"
$SPSite = Get-SPSite "http://xxx.xxxxx.org.uk" 
foreach ($SPWeb in $SPSite.AllWebs) 
{
  $fontSchemeUrl = $SPWeb.Url+ ""
  $themeurl = $SPWeb.Url + "/_catalogs/theme/15/Palette032.spcolor"
  $imageUrl = $SPWeb.Url + ""
  $SPWeb.ApplyTheme($themeUrl, $fontSchemeUrl, $imageUrl, $false);
  Write-Host "Set" $themeName "at :" $SPWeb.Title "(" $SPWeb.Url ")" 
  $SPWeb.Dispose()
}  
$SPSite.Dispose()

PS. You don't need allowunsafeupdates in PowerShell :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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