1

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.

0

You can use below snippet to set the site logo

$ClientContext.Web.SiteLogoUrl = "http://logourl";
$ClientContext.Web.Update()
$ClientContext.ExecuteQuery()

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 
$ClientContext.Load($Web) 
$ClientContext.ExecuteQuery() 

function Get-SPOAllWebs{ 
    Param( 
    [Microsoft.SharePoint.Client.ClientContext]$ClientContext, 
    [Microsoft.SharePoint.Client.Web]$Root 
    ) 

    $Webs = $Root.Webs 
    $ClientContext.Load($Webs) 
    $ClientContext.ExecuteQuery() 

    ForEach ($w in $Webs) 
    { 
        #Logic to update SITELOGO
        Get-SPOAllWebs -RootWeb $w -Context $ClientContext
    } 
}
  • 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

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.