Forum Discussion
SharePoint Online Site Branding
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"
}
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_jenkinsApr 11, 2025Steel 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.
- grant_jenkinsApr 11, 2025Steel Contributor
Adding to my post above. It seems that Set-PnPWebTheme is only available for the old themes we added manually (JSON colors). From some further investigation, there doesn't seem to be a way to programmatically apply the new themes to sites which is a major gap (another gap in the overall Modern Branding solution).
When you create a new Theme in the Brand Center it should show as an option to select in Change the look > Theme across each site - but auto applying looks "potentially" not possible. I'll keep researching and get back to you.