Is it possible to create a script that will loop through all the sites in a site tenancy to replace the logo that is attached to each one. I'm unable to locate any useful commands in the SPO Commandlet set.


You can use below snippet to set the site logo

$ClientContext.Web.SiteLogoUrl = "http://logourl";

Below snippet can be used to get all sites

$SecurePassword = ConvertTo-SecureString "PassWord" -AsPlainText -Force 
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("UserName", $SecurePassword) 
$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext("SiteUrl") 
$ClientContext.Credentials = $Cred

$Web = $ClientContext.Web 

function Get-SPOAllWebs{ 

    $Webs = $Root.Webs 

    ForEach ($w in $Webs) 
        #Logic to update SITELOGO
        Get-SPOAllWebs -RootWeb $w -Context $ClientContext
| improve this answer | |
  • Was this taken from a blog? I think I came across something like this when googling. What are the dependencies? Get-SPOAllsites for instance isn't an OOB command as far as I can see but an additional script from TechNet. gallery.technet.microsoft.com/office/… What else would I need to install? – Steven D Andrews Oct 3 '17 at 12:49
  • You need to recursively query to get all the webs.. hence we need to create a function and call it. The initial source was from a blog which I modified and using it. – Amal Hashim Oct 3 '17 at 12:52

this one works for me: https://github.com/t1llo/change_logo_SharePointOnline-PS

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Ctx.Credentials = $Credentials

#Get the Root web
$Web = $Ctx.Web

#Function to change Logo for the given web
Function Update-Logo($Web)
    #Update Logo
    $Web.SiteLogoUrl = $LogoURL

full code on https://github.com/t1llo/change_logo_SharePointOnline-PS

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.