SharePoint Online: How to Change the Site Logo using PowerShell?
Requirement: Change the Logo in SharePoint Online site.
How to Change Logo in SharePoint Online?
Are you looking to change your SharePoint Online logo? Well, a logo change is a common requirement when it comes to branding SharePoint Online sites. Perhaps you want to update your company’s new logo to make it more consistent with your branding. In this article, we’ll walk you through the process step-by-step. We will also show you how to change the logo on your SharePoint Online site using PowerShell.
How do I add a logo to my SharePoint Online site? To set a logo in SharePoint Online, follow these steps:
- Log in as a Site Administrator to your SharePoint Online site. Click on Settings gear >> Select Site Settings >> In the Site settings page, click on “Title, description, and logo” link (/_layouts/15/prjsetng.aspx).
- That takes you to a page where you can set a 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” Document Library of the site.
As soon as you upload an image for the logo, You’ll find the new logo reflected immediately on the top left-hand side of the site. Optionally, you can enter a logo description, and this description becomes a tooltip for your new logo. Click on the “OK” button to save your changes. Click Cancel to discard.
That’s it! Your new logo will now be visible on your classic experience SharePoint Online site.
SharePoint Online: How to Change Logo in Modern Sites
Unlike the classic version of SharePoint sites, changing the site logo for a Modern team site and communication site is straightforward indeed, and it can be achieved in a few clicks.
- Navigate to the Modern SharePoint Site as site owner >> Click on Settings gear icon >> Click on “Change the look” from the site settings menu.
- In the change the look panel, click on the “Header” link.
- Now, you can click on the “Change” button under “Site Logo” to browse any supported logo image as the logo for your site. Once the image is uploaded, you see the preview of the image. This logo will be used in the site header.
- Click Save to apply your changes.
You can also change the site logo thumbnail with a square logo to appear in search and site cards. If you want to revert to the default SharePoint logo, click on the “Remove” button.
SharePoint Online PowerShell to Change Logo:
Changing the logo from web UI is pretty simple, isn’t it? Well, what if you have a site collection with hundreds of sub-sites and sub-sub-sites? What if different sites use different versions of your company logo and want to make them consistent? PowerShell is the answer! Let’s use the PowerShell script to change the site logo in SharePoint Online.
#Add PowerShell Module for SharePoint Online
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
}
Please note that the file URL at LogoURL must be an existing file on the SharePoint Online site. So, upload the logo to the root of your site collection first.
PowerShell to Change the site logo for a site collection and its subsites:
Let’s change the logo for all sites within a SharePoint Online site collection. Make sure you have uploaded the “logo.png” file in the site assets library before executing this script.
#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 to change sharepoint site logo
Update-Logo($Subsite)
}
}
#Call the function to change the logo of the web
Update-Logo($Web)
}
Catch {
write-host -f Red "Error updating Logo!" $_.Exception.Message
}
PnP PowerShell to Change Logo for All Sites in a SharePoint Online Site Collection
Let’s set the logo on each web in the site collection this time. Instead of referring to the logo from the top-level web, let’s upload it to each site and then use PnP PowerShell to change the site logo in SharePoint Online.
#Function to set site Logo
Function Set-PnPSiteLogo
{
[cmdletbinding()]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $false)]$Web,
[parameter(Mandatory = $true, ValueFromPipeline = $false)][String] $LogoFilePath
)
Try {
Write-host "Updating Logo on Site '$($Web.URL)'"
Connect-PnPOnline -Url $Web.URL -Interactive
#Ensure "Site Assets" library in the site
$SiteAssets = Get-PnPList -Identity "Site Assets" -ErrorAction SilentlyContinue
If($SiteAssets -eq $Null)
{
New-PnPList -Title "Site Assets" -Template DocumentLibrary -Url "SiteAssets" -ErrorAction SilentlyContinue | Out-Null
}
#Upload Logo File to 'Site Assets' library of the current web
Add-PnPFile -Path $LogoFilePath -Folder "SiteAssets" | Out-Null
#Get File Name from Logo File's Full Path
$LogoFileName = Split-Path $LogoFilePath -leaf
#Set Site Logo
Set-PnpWeb -SiteLogoUrl "$($Web.ServerRelativeUrl)/SiteAssets/$($LogoFileName)"
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Marketing"
$LogoPath = "C:\Temp\Logo.jpg"
#Connect to Site
Connect-PnPOnline -Url $SiteURL -Interactive
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
#Call the function to change site logo
$Webs | ForEach-Object { Set-PnPSiteLogo -Web $_ -LogoFilePath $LogoPath }
However, this PowerShell works only for non-group connected sites!
How to Change Logo on Modern Group Connected Sites?
If the site is created in Office 365 Groups or Microsoft Teams, Then the logo changed in those apps doesn’t reflect back to SharePoint Online. Simply replace the file “__siteIcon__.jpg” under the “Site Assets” library (create one if it doesn’t exist!) to change the site logo!
If you want to set the site logo for Modern group connected sites with PowerShell, use the Set-PnPSite cmdlet with the “LogoFilePath” Parameter:
$SiteURL = "https://crescent.sharepoint.com/sites/Purchase"
$LogoPath = "C:\Temp\Logo.jpg"
#Connect to Site
Connect-PnPOnline -Url $SiteURL -Interactive
#Set Site Logo
Set-PnPSite -LogoFilePath $LogoPath
When trying to change the site logo in group connected sites, I got an error message: “We experienced a problem updating the icon. Please try again in a few minutes.” This is because: The user who tried changing the site logo was not the Group owner! Just add the user as Office 365 Group Owner, and he should be able to change the site logo!
How to change the site logo in the entire tenant for all sites and subsites?
This PowerShell script iterates through each SharePoint site collection in the Microsoft 365 tenant and updates the Logo from the parameters. This script can handle both classic sites and modern group-connected sites.
#Parameters
$Domain = "Crescent" #Your Domain Name in SharePoint Online. E.g. https://Crescent.SharePoint.com
$LogoFilePath = "C:\Temp\SPLogo.jpg"
$Cred = Get-Credential
#Frame Tenant URL and Tenant Admin URL
$TenantURL = "https://$Domain.SharePoint.com"
$TenantAdminURL = "https://$Domain-Admin.SharePoint.com"
#Function to set site Logo
Function Set-PnPSiteLogo
{
[cmdletbinding()]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $True)]$Web,
[parameter(Mandatory = $true, ValueFromPipeline = $False)][String] $LogoFilePath
)
Try {
Connect-PnPOnline -Url $Web.URL -Credentials $Cred
#Ensure "Site Assets" library in the site
$SiteAssets = Get-PnPList -Identity "Site Assets" -ErrorAction SilentlyContinue
If($SiteAssets -eq $Null)
{
New-PnPList -Title "Site Assets" -Template DocumentLibrary -Url "SiteAssets" -ErrorAction SilentlyContinue | Out-Null
}
#Upload Logo File to 'Site Assets' library of the current web
Add-PnPFile -Path $LogoFilePath -Folder "SiteAssets" | Out-Null
#Get File Name from Logo File's Full Path
$LogoFileName = Split-Path $LogoFilePath -leaf
#Set Site Logo
Set-PnpWeb -SiteLogoUrl "$($Web.ServerRelativeUrl)/SiteAssets/$($LogoFileName)"
Write-host "`n`tUpdated Logo on Web '$($Web.URL)'" -f Green
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude BOT, Video Portals and MySites
$Sites = Get-PnPTenantSite -Filter "Url -like $TenantURL -and Url -notlike '-my.sharepoint.com/' -and Url -notlike '/portals/'"
#Iterate through all site collections
$Sites | ForEach-Object {
#Connect to each site collection
Connect-PnPOnline -Url $_.URL -Credentials $Cred
Write-host "Processing Site Collection:"$_.URL -f Yellow -NoNewline
#Check if its a Group site
If($_.Template -like 'GROUP*')
{
Set-PnPSite -LogoFilePath $LogoFilePath
Write-host "`n`tUpdated Logo on Group Site!" -f Green
}
Else
{
#Call the Function for site & all Subwebs
Get-PnPSubWeb -Recurse -IncludeRootWeb | ForEach-Object { Set-PnPSiteLogo -Web $_ -LogoFilePath $LogoFilePath }
}
}
How about changing the Header Layout, Site logo, and background in modern SharePoint Online sites? Here you go: How to Change Header Layout, Site Logo, Background in SharePoint Online using PowerShell?
What about updating the Header Site Logo and Background Image?
Here you go: SharePoint Online: Change Header Layout, Site Logo, Background using PowerShell
we have an automated method to create site collections, can we change the site logo with logo saved in one of the root/home site collection and reference it when changing the site logo? rather than logo saved on a machine?
please advise?
The PnP PowerShell script uploads the Logo to each site assets before referencing it as a Logo of the site. If your logo is stored somewhere in the root site where everyone has access to it, Yes! You can reference it.
Thank you so much this is the only work-around that really worked for me. Apparently people also suggested another approach which I simply couldn’t follow due to the complex and risks of services of my site.
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
How to redirect the logo “click URL” to redirect to the root site collection?
PS C:\WINDOWS\system32> Set-SPOSiteLogo -Web $Web -LogoURL $LogoURL
Set-SPOSiteLogo : No se puede procesar la transformación del argumento del parámetro ‘Web’. No se puede convertir el
valor “Microsoft.SharePoint.Client.Web” de tipo “Microsoft.SharePoint.Client.Web” al tipo
“Microsoft.SharePoint.Client.Web”.
En línea: 1 Carácter: 22
+ Set-SPOSiteLogo -Web $Web -LogoURL $LogoURL
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Set-SPOSiteLogo], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-SPOSiteLogo
Hi Salaudeen,
How to change site collection URL in SharePoint Online?
Thanks.
Unfortunately, its not possible to rename site collection URL’s in SharePoint Online as of Today! The only alternate is to create a new site collection and copy content over.