Skip to content

Commit 4a233ce

Browse files
authored
Updated PnP PowerShell on applying a theme
The sample PowerShell on applying a theme to SharePoint was still using CSOM while native PnP commands are available now to set a theme. Updated the sample to use this cmdlet.
1 parent 44eba35 commit 4a233ce

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

docs/solution-guidance/modern-experience-customizations-customize-sites.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ The following elements are ignored when a remote template is applied to a "moder
104104
```powershell
105105
106106
# Connect to a previously created Modern Site
107-
$cred = Get-Credential
108-
Connect-PnPOnline https://[tenant].sharepoint.com/sites/siteurl -Credentials $cred
107+
Connect-PnPOnline https://[tenant].sharepoint.com/sites/siteurl -UseWebLogin
109108
110109
# Apply a custom theme to a Modern Site
111110
@@ -114,16 +113,7 @@ Add-PnPFile -Path .\sppnp.spcolor -Folder SiteAssets
114113
Add-PnPFile -Path .\sppnp-bg.png -Folder SiteAssets
115114
116115
# Second, apply the theme assets to the site
117-
$web = Get-PnPWeb
118-
$palette = $web.ServerRelativeUrl + "/SiteAssets/sppnp.spcolor"
119-
$background = $web.ServerRelativeUrl + "/SiteAssets/sppnp-bg.png"
120-
121-
# We use OOTB CSOM operation for this
122-
$web.ApplyTheme($palette, [NullString]::Value, $background, $true)
123-
$web.Update()
124-
# Set timeout as high as possible and execute
125-
$web.Context.RequestTimeout = [System.Threading.Timeout]::Infinite
126-
$web.Context.ExecuteQuery()
116+
Set-PnPTheme -ColorPaletteUrl "SiteAssets/sppnp.spcolor" -BackgroundImageUrl "SiteAssets/sppnp-bg.png" -ResetSubwebsToInherit
127117
128118
```
129119

0 commit comments

Comments
 (0)