Branding in SharePoint Online ensures visual consistency, improved user experience, and better corporate identity across multiple sites. Using PnP PowerShell, administrators can efficiently apply themes, logos, headers, and footers to multiple SharePoint sites.
Why use PnP PowerShell for Branding?
- Automates theme application across multiple sites
- Saves time compared to manual configuration
- Ensures consistent branding across an organization
Prerequisites
Before running PnP PowerShell commands:
Install PnP PowerShell (if not installed)
Install-Module -Name PnP.PowerShell -Force -AllowClobber
Connect to SharePoint Online
Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive
Ensure permissions
- You must be a SharePoint Admin or Site Owner
Step 1: Apply a Custom Theme
To apply a custom theme across multiple sites, first, define the theme in a JSON file.
Example: JSON Theme File (custom-theme.json
)
{
"palette": {
"themePrimary": "#0078d4",
"themeSecondary": "#2b88d8",
"themeTertiary": "#71afe5",
"themeDarkAlt": "#106ebe",
"themeDark": "#005a9e"
},
"isInverted": false,
"name": "Company Theme"
}
✔️ Save the JSON file as custom-theme.json
.
Upload and apply the theme using PowerShell
$themeJson = Get-Content -Raw -Path "C:\custom-theme.json"
Add-PnPTenantTheme -Identity "Company Theme" -PaletteJson $themeJson -IsInverted $false
Adds the theme to the SharePoint Tenant.
Apply the theme to multiple sites
$sites = @("https://yourtenant.sharepoint.com/sites/Site1",
"https://yourtenant.sharepoint.com/sites/Site2")
foreach ($site in $sites) {
Connect-PnPOnline -Url $site -Interactive
Set-PnPWebTheme -Theme "Company Theme"
}
Applies the Company Theme to all listed sites.
Step 2: Set a Custom Logo
To set a site logo for multiple sites:
$sites = @("https://yourtenant.sharepoint.com/sites/Site1",
"https://yourtenant.sharepoint.com/sites/Site2")
foreach ($site in $sites) {
Connect-PnPOnline -Url $site -Interactive
Set-PnPWeb -SiteLogoUrl "https://yourtenant.sharepoint.com/sites/branding/logo.png"
}
Updates the logo for all specified sites.
Step 3: Configure the Header Layout
To change the site header style (e.g., compact, standard, extended, minimal):
Set-PnPWeb -HeaderLayout Extended
Sets the Extended Header layout.
For multiple sites:
$sites = @("https://yourtenant.sharepoint.com/sites/Site1",
"https://yourtenant.sharepoint.com/sites/Site2")
foreach ($site in $sites) {
Connect-PnPOnline -Url $site -Interactive
Set-PnPWeb -HeaderLayout Compact
}
Applies a Compact Header across all sites.
Step 4: Set the Footer Configuration
To enable and configure a SharePoint footer:
Set-PnPWeb -FooterEnabled $true -FooterLayout Simple
Enables a simple footer for the site.
For multiple sites:
$sites = @("https://yourtenant.sharepoint.com/sites/Site1",
"https://yourtenant.sharepoint.com/sites/Site2")
foreach ($site in $sites) {
Connect-PnPOnline -Url $site -Interactive
Set-PnPWeb -FooterEnabled $true -FooterLayout Extended
}
Enables and applies an Extended Footer across all sites.
Step 5: Automating the Branding Process
You can automate branding updates weekly or monthly using a scheduled PowerShell script:
$logPath = "C:\Logs\BrandingLog_$(Get-Date -Format 'yyyyMMdd').txt"
function Apply-Branding {
param ($siteUrl)
Connect-PnPOnline -Url $siteUrl -Interactive
Set-PnPWebTheme -Theme "Company Theme"
Set-PnPWeb -SiteLogoUrl "https://yourtenant.sharepoint.com/sites/branding/logo.png"
Set-PnPWeb -HeaderLayout Compact
Set-PnPWeb -FooterEnabled $true -FooterLayout Extended
"[$(Get-Date)] Applied branding to $siteUrl" | Out-File -Append -FilePath $logPath
}
$sites = @("https://yourtenant.sharepoint.com/sites/Site1",
"https://yourtenant.sharepoint.com/sites/Site2")
foreach ($site in $sites) {
Apply-Branding -siteUrl $site
}
Logs branding updates for monitoring.
Step 6: Verify Branding Application
To check the applied theme on a site:
Get-PnPWebTheme
To confirm branding settings:
Get-PnPWeb | Select Title, SiteLogoUrl, HeaderLayout, FooterEnabled
Displays current branding settings.
Troubleshooting Issues
1️⃣ Branding Not Applied?
Ensure PnP.PowerShell is updated
Update-Module PnP.PowerShell
Verify that the theme exists using
Get-PnPTenantTheme
2️⃣ Logo Not Updating?
Ensure the logo URL is accessible
Try re-uploading the logo
3️⃣ PowerShell Script Failing?
Run PowerShell as Administrator
Check for correct site URLs