Forum Discussion

Ebol19's avatar
Ebol19
Copper Contributor
Apr 09, 2025

SharePoint Online Site Branding

Hello, 

I am currently trying to figure out a way to automatically (Powershell) copy and apply custom Site Branding from one site collection to all site collections in tenant, does anyone have any ideas as so far i am not getting very far. 

  • grant_jenkins's avatar
    grant_jenkins
    Steel Contributor

    I guess it depends on what you mean by "custom Site Branding".

    Is this using the new Site branding feature? If so, then if you have the Brand Center configured you can add it in there and make it available to all sites in the tenant. That won't apply the theme to the sites though - so you'd still need PowerShell to do this part. You could try Set-PnPWebTheme: Set-PnPWebTheme | PnP PowerShell.

    Are you able to clarify what your "custom Site Branding" is?

     

    If you were just referring to old school JSON values for the colors, you might be able to do something like that below. Note that you should test any scripts thoroughly (including this) in a test environment first to ensure it runs as expected. I haven't tested this in my tenant but believe it "should" work as expected.

    This assumes you have access to your sites via delegated permissions. Otherwise, you might need an App registration with Application permissions. I've also omitted most of the colors for simplicity.

    $themePaletteRed = @{
        "themePrimary" = "#580720";
        "themeLighterAlt" = "#f3f1ee";
        "themeLighter" = "#fbeee6";
        "themeLight" = "#e59190";
        "themeTertiary" = "#580720";
        "themeSecondary" = "#580720";
    }
    
    Connect-PnPOnline -Url "https://YOUR_TENANT-admin.sharepoint.com" -ClientId "YOUR_APP_REG_GUID" -Interactive
    
    $sites = Get-PnPTenantSite | Select Url
    
    foreach($site in $sites) {
    
        Connect-PnPOnline -Url $site.Url -ClientId "YOUR_APP_REG_GUID" -Interactive
    
        Add-PnPTenantTheme -Identity "My Red Theme" -Palette $themePaletteRed -IsInverted $false -Overwrite
    
        #Apply a theme to a particular site
        Set-PnPWebTheme -Theme "My Red Theme"
    
    }

     

    • Ebol19's avatar
      Ebol19
      Copper Contributor

      Hi Grant, 

      Thanks for your response.

      It is new Site Branding indeed, I have it configured under our Org Assets site which is set as the Brand center site but the option doesn't appear across other sites in tenant. Do i have to do anything else to make it available or should it be automatic ? 

      I do have ability to write up a script to apply theme across once its available, i just thought it would be good to figure the Site Branding out as this seems to be way forward.

      • grant_jenkins's avatar
        grant_jenkins
        Steel Contributor

        If you're using the Site branding on a specific site (even the Brand Center site) then that will only be available for that site.

        If you want a theme to be available to apply across all your sites, you will need to go into the Brand Center and create a new Theme for SharePoint. However, as far as I know, there is no way to apply the theme across sites from within the Brand Cener - only make it available for users to choose within Change the look > Theme.

        If you want to apply it to all your sites, then it would be a similar process to what I provided before - see below. Note that I would also suggest only targeting Modern sites (Communication and Modern Team sites - so might need to add some filtering in the script to cater for that).

        Connect-PnPOnline -Url "https://YOUR_TENANT-admin.sharepoint.com" -ClientId "YOUR_APP_REG_GUID" -Interactive
        
        $sites = Get-PnPTenantSite | Select Url
        
        foreach($site in $sites) {
        
            #Apply a theme to a particular site - this assumes you have created a theme called "My Red Theme" in the Brand Center
            Set-PnPWebTheme -Theme "My Red Theme" -WebUrl $site.Url
        
        }

        However - I just tried this in my tenant and it's applying themes that I added manually (old school) but throws an error for themes created via the Brand Center which is interesting - I'll do some more investigation.

Resources