Pages

Monday, September 16, 2013

SharePoint 2010 PoweShell Update Site CSS and Logo




Are you moving from one environment to another? Or just have to change the css and site logo for a large SharePoint farm, with many top Level Site Collections. I had this happen to me about 2 weeks ago. I had to update the Top Level Sites Collections CSS, and Logo URL for 35 sites. Come in PowerShell! PowerShell is a great administration tool that can help you automate and stream line your task. I used the following script to accomplish the task I needed.



Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$WA = Get-SPWebApplication "Web Application URL"
$Sites = $WA.Sites

foreach($Site in $Sites)
{
        foreach($web in $site.AllWebs)
        {
            Write-Host  $web.Url  "   CSS URL: "   $web.AlternateCssUrl
            
            Write-Host  $web.Url  "   Logo URL: "   $web.SiteLogoUrl
            
            $web.AlternateCssUrl = "New CSS URL"
            $web.SiteLogoUrl = "NEW Logo URL"
            $web.Update() 
            Write-Host "updated: "  $web.Url
        }
}