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, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply

16 replies on “Changing site logo for all sub sites in a Site collection for SharePoint Online (Office 365)”

  • Joe Heikenfeld
    August 18, 2017 at 11:59 pm

    Excellent Adnan

  • August 25, 2017 at 1:43 am

    I constantly emailed this weblog post page to all my contacts, because if like to
    read it then my friends will too.

    • August 28, 2017 at 6:53 pm

      Thanks alot, I really appropriate for spreading the word to the community.

  • August 25, 2017 at 10:22 am

    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!

    • August 28, 2017 at 6:54 pm

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

  • August 26, 2017 at 3:05 am

    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…

  • August 28, 2017 at 1:27 am

    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!

  • August 28, 2017 at 4:53 am

    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?

  • August 28, 2017 at 5:29 pm

    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!

  • September 1, 2017 at 2:23 am

    What’s up, just wanted to tell you, I enjoyed this blog
    post. It was practical. Keep on posting!

  • September 1, 2017 at 10:23 am

    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.

  • September 1, 2017 at 4:26 pm

    Mapping Office Attributes to OneLogin Attributes.