2

I have a SharePoint 2013 environment where I want to apply a single Alternate CSS file across all site collections and subsites. I am using the following method. When I run this I receive a single error, the Alternate CSS is applied to all sites and subsites EXCEPT on the root site collection. Any ideas how I can get this to work for the root site collection as well?

$Webapp = Get-SPWebApplication "http://MyServer/"

$Sites = $Webapp.sites.url
foreach ($site in $sites)
{
  $web = Get-SPWeb $site
  $cssurl = "/SiteAssets/DevColorChange.css"
  $web.AlternateCssUrl = $cssurl
  $web.AllProperties["__InheritsAlternateCssUrl"] = $True
  $web.Update()
}

ERROR:

Exception calling "Update" with "0" argument(s): "Specified data type does not match the current data type of the property." At line:10 char:1 + $web.Update() + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SPInvalidPropertyException

1 Answer 1

4
Get-SPWebApplication "http://MyServer/" | Get-SPSite -Limit All | Get-SPWeb -Limit All | % { $_.AlternateCssUrl = ($_.Site.Url + "/SiteAssets/DevColorChange.css");$_.Update() }
2

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.