In the same development project I mentioned in my last post we had the necessity to modify the SharePoint Team Site site icon on every Team Site located in a site collection. You can modify this manually in the Site Settings under “Title, description, and icon”.
Therefore, I wanted to write a PowerShell script to update all icons in a row.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$siteUrl = "http://foundation"
$siteLogo = "/SiteAssets/logo.png"
$rootSite = Get-SPSite $siteUrl
$allWebs = $rootSite.AllWebs
foreach ($web in $allWebs) {
Write-Host "Updating " + $web.Title + " " + $web.Url
$web.SiteLogoUrl = $siteLogo
$web.Update()
}
As you can see from the straightforward script above we are going through all sub-sites of a site collection defined und “$siteUrl”. The root site stores a “logo.png” with the icon under the “SiteAssets” library.
The foreach loop is simply updating the SiteLogoUrl of every sub-site with the relative URL defined under “siteLogo”.
Hope this helps,
Patrick