Changing site logo for all sub sites in a Site collection for SharePoint Online (Office 365)

In my previous article, I shared details for changing site logo for a site collection and its sub sites using PowerShell, but that was only for on-premise environment. PowerShell script for SharePoint Online is different from on-premise where we refer SharePoint client dlls, make sure you should have installed SharePoint Online Management Shell, if not then you can download it from this link.

I have update the script at technet gellery for changing site logo for both SharePoint On-Premise as well as for SharePoint Online, you can download it from this link.

MsTechtalk Technet gallery

Below is the PowerShell script which update the site logo for all sub sites under a site collection, it will ask you for site URL, user name and password.


$siteUrl = Read-Host -Prompt “Enter site collection URL (” #you can also set the site URL
$userToLogin = Read-Host -Prompt “Enter Username” #you can also set the user name, make sure it should be global admin
$password = Read-Host -Prompt “Enter Password” -AsSecureString
$sitelogoURL = “/SiteAssets/newSitelogo.gif” #change the site logo
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userToLogin, $password)

$clientContext.Credentials = $credentials

$web = $clientContext.get_web()
$webs = $clientContext.Web.Webs;


function updateSubSites($subWeb) {
$subsites = $subWeb.Webs;
foreach ($subSite in $subsites) {

function updateSiteLogo($subWeb) {
$subWeb.SiteLogoUrl = $sitelogoURL

Write-Host “Updated logo for ” $subWeb.Title ” , site url:” $subWeb.Url


foreach ($subWeb in $webs)
write-host “inside bottom foreach”

You might get below exception if the user is not global admin, so make sure you have credentials for global admin.

Exception calling “ExecuteQuery” with “0” argument(s): “The Login server cannot issue the requested compact encrypted ticket because a Data Encryption Key (DEK) has not been uploaded to the site.”

At line:19 char:1

+ $clientContext.ExecuteQuery()

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : IdcrlException

Adnan Amin

Adnan is two time SharePoint MVP (Most Valuable Professional) with over 12 years of extensive experience with major expertise on SharePoint Server, Office 365, .Net Platform and Microsoft BI. He is currently working SharePoint Architect at FMT Consultants. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past nine years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions. He is a trainer, technology evangelist and also speaks in community forums.

This Post Has 17 Comments

  1. My developer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on a variety of websites for about a year and
    am anxious about switching to another platform. I have heard great things about Is there a way I can import all my wordpress content into it?
    Any help would be greatly appreciated!

    1. I have used 10 years back, I think there must be some plugin which can import all blog posts for you.

  2. I need to to thank you for this good read!! I absolutely loved every bit of it.
    I have you book marked to check out new stuff you post…

  3. Please let me know if you’re looking for a writer
    for your site. You have some really good articles and I
    think I would be a good asset. If you ever want to take some
    of the load off, I’d really like to write some material for your blog
    in exchange for a link back to mine. Please shoot me an e-mail
    if interested. Thank you!

  4. Oh my goodness! Incredible article dude! Thank you so much, However I
    am encountering problems with your RSS. I don’t know the reason why I can’t join it.
    Is there anybody having the same RSS problems?
    Anyone who knows the answer can you kindly respond?

  5. My brother recommended I would possibly like this blog.
    He used to be totally right. This putt up truly mawde my
    day. You can noot believe simply how so much time I had spent for
    this info! Thank you!

  6. Hmm is anyone else having problems with the images on this blog loading?
    I’m trying to figure out if its a problem on my end
    or if it’s the blog. Any feedback would be greatly appreciated.

Leave a Reply