Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

SharePoint Online: How to Change Site Logo using PowerShell?

$
0
0
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
}

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>