1

I'm trying to set the $web.alternateCSSUrl property, but it doesn't seem to work.

It's populating the "All Channels" box with the correct URL to the CSS, and I set it in the code, but I can only find out how to select the radio button "Inherit Alternate CSS URL from parent of this site" which is NOT what I want, rather, I think I have select the third radio button for it to be activated. See picture:

How can I turn this third radio button on? Not too sure what to put inside to index the hashtable of $web.AllProperties.

enter image description here

Code:

function applyCSSToMasterPage($webNode, $web, $cssLocation)
{
    if ([string]::IsNullOrEmpty($cssLocation))
    {
        return;
    }
    else
    {
        try
        {
            $web.alternateCSSUrl = $cssLocation;
            $web.AllProperties["__InheritsAlternateCssUrl"] = "True";
            $web.Update();
        }
        Catch [System.Exception]
        {
            Write-Host "There was a problem with either the location of the CSS file or update()" -BackgroundColor DarkRed;
            return;
        }
        Write-Host "CSS Updated in Master Page for $webNode.Title" -BackgroundColor DarkMagenta;
    }

}
  • Maybe try not setting the __InheritsAlternateCssUrl property at all? Or set it to $false? – Dylan Cristy Jan 13 '16 at 21:08
  • How are you using the $webNode parameter vs. $web? – boflynn Feb 12 '16 at 15:30

Your Answer

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

Browse other questions tagged or ask your own question.