Changing logo is a common requirement when it comes to branding SharePoint online sites.
How to change Logo in SharePoint Online:
Changing logo in sharepoint online is a matter of few clicks. To add logo to sharepoint online, follow these steps
Lets use PowerShell script to change site logo in SharePoint online.
PowerShell to Change the site logo for a site collection and its sub sites:
Lets change logo for all sites within a SharePoint online site collection.
How to change Logo in SharePoint Online:
Changing logo in sharepoint online is a matter of few clicks. To add logo to sharepoint online, follow these steps
- Login as a site Administrator to your SharePoint Online site. Click on Settings gear >> Select Site Settings >> On Site settings page, Click on "Title, description, and logo" link.
- That takes you to a page where you can set Logo for the site. you can use either a logo from your computer, or any existing logo from your SharePoint site (Even any existing image from the Internet too).
- Click on "From Computer" link >> Browse and upload your logo file. Once you upload, the logo file gets saved into "Site Assets" Library of the site.
Lets use PowerShell script to change site logo in SharePoint online.
#Add PowerShell Module for SharePoint OnlinePlease note, the file URL at LogoURL must be an existing file in SharePoint online site. So, upload the logo to root of your site collection first.
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking
##Configuration variables
$SiteUrl = "https://crescent.sharepoint.com/"
$LogoURL="/SiteAssets/Logo.png" #Existing file
Try {
#Get Credentials to connect
$Cred = Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Ctx.Credentials = $Credentials
$Web = $Ctx.Web
#Change Logo
$Web.SiteLogoUrl = $LogoURL
$Web.Update()
$Ctx.ExecuteQuery()
Write-host "Logo Updated Successfully!" -ForegroundColor Green
}
Catch {
write-host -f Red "Error updating Logo!" $_.Exception.Message
}
PowerShell to Change the site logo for a site collection and its sub sites:
Lets change logo for all sites within a SharePoint online site collection.
#Add PowerShell Module for SharePoint Online
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking
##Configuration variables
$SiteUrl = "https://crescent.sharepoint.com/Sites/Sales"
$LogoURL="/SiteAssets/Logo.png"
Try {
#Get Credentials to connect
$Cred = Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Ctx.Credentials = $Credentials
#Get the Root web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Function to change Logo for the given web
Function Update-Logo($Web)
{
#Update Logo
$Web.SiteLogoUrl = $LogoURL
$Web.Update()
$Ctx.ExecuteQuery()
Write-host "Updated Logo for Web:" $Web.URL
#Process each subsite in the site
$Subsites = $Web.Webs
$Ctx.Load($Subsites)
$Ctx.ExecuteQuery()
Foreach ($SubSite in $Subsites)
{
#Call the function Recursively
Update-Logo($Subsite)
}
}
#Call the function to change logo of the web
Update-Logo($Web)
}
Catch {
write-host -f Red "Error updating Logo!" $_.Exception.Message
}