DEV Community

Miguel Isidoro
Miguel Isidoro

Posted on • Originally published at blogit.create.pt on

3 2

SharePoint 2016: Changing logo for all sites in a site collection using PowerShell

The post SharePoint 2016: Changing logo for all sites in a site collection using PowerShell appeared first on Blog IT.

Hello,

In a SharePoint 2010 to SharePoint 2016 migration project I was recently involved in, I noticed that in the new SharePoint 2016 Portal, the logo URL in all sites was pointing to an invalid URL.

The Problem

The reason for this is that the Logo URL was pointing to a URL in the SharePoint hive (_layouts virtual directory) and the _layouts virtual directory URL has changed from SharePoint 2010 to SharePoint 2016:

  • SharePoint 2010 Layouts root virtual directory URL: /_layouts
  • SharePoint 2016 Layouts root virtual directory URL: /_layouts/15

The Solution

Since the site collection has a lot of subsites and I would like to avoid having to change the logo URL manually one by one, I built a small PowerShell script that will loop all the sub sites in the site collection and change the Logo URL for each one. Here is the script:

$sitelogo = "/_layouts/15/Images/logo.jpg"

$site = "https://intranet"

$sites = new-object Microsoft.SharePoint.SPSite($site)

foreach ($web in $sites.Allwebs) {

$webUrl = $web.Url

"Changing site logo url at $webUrl"

$web.SiteLogoUrl = $sitelogo

$web.Update()

}

$sites.Dispose()

If you are a SharePoint developer or administrator and want to learn more on how to install a SharePoint 2016 farm in an automated way using PowerShell click here and here.

If you want to know all about SharePoint 2019, the upcoming version of SharePoint Server, click here.

If you are new to SharePoint and Office 365 and want to learn all about it, take a look at these learning resources.

NOTE: This script should also be valid for SharePoint 2013 and SharePoint 2019.

Hope this helps!

Happy SharePointing!

The post SharePoint 2016: Changing logo for all sites in a site collection using PowerShell appeared first on Blog IT.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay