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.