kwizcom banner advertisement

SharePoint Online: How to Change Site Logo using PowerShell?

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
  • 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.
    SharePoint Online PowerShell Change Logo
  • 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.SharePoint Online How to Change Site Logo using PowerShell
  • As soon as you upload a image for logo, You'll find the new logo reflected immediately in the top left hand side of the site. Optionally, you can enter description for the logo. This description becomes tool tip for your new logo. Click on "OK" button to save your changes. Click cancel to discard.
SharePoint Online PowerShell to Change Logo:
Lets use PowerShell script to change 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, 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.

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
}
SharePoint Online: How to Change Site Logo using PowerShell? SharePoint Online: How to Change Site Logo using PowerShell? Reviewed by Salaudeen Rajack on 5:06 PM Rating: 5

2 comments:

  1. Hi Salaudeen,

    How to change site collection URL in SharePoint online?

    Thanks.

    ReplyDelete
    Replies
    1. 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.

      Delete

Please Login and comment to get your questions answered!

Powered by Blogger.