SOLVED
Home

Using PowerShell to change page banner image

%3CLINGO-SUB%20id%3D%22lingo-sub-292238%22%20slang%3D%22en-US%22%3EUsing%20PowerShell%20to%20change%20page%20banner%20image%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-292238%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Folks%2C%3CBR%20%2F%3E%3CBR%20%2F%3ECurrently%20have%20a%20automatic%20site%20creation%20tool%20up%20and%20running.%20I%20know%20using%20the%20PnP%20engine%20no%20content%20will%20be%20included%20in%20the%20template%2C%20but%20is%20there%20any%20way%20on%20the%20newly%20created%20site%20on%20the%20main%20home%20page%20(Modern%20Page)%20I%20can%20change%20the%20banner%20image%20using%20PowerShell%20to%20reference%20an%20image%20stored%20somewhere%20else%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-292238%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EModern%20Site%20Page%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-292455%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PowerShell%20to%20change%20page%20banner%20image%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-292455%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Rahul%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20response.%3C%2FP%3E%3CP%3EDropped%20the%20Publishing%20from%20the%20script%20and%20worked.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-292428%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PowerShell%20to%20change%20page%20banner%20image%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-292428%22%20slang%3D%22en-US%22%3E%3CP%3EBlair%2C%3C%2FP%3E%3CP%3EI%20believe%20you%20are%20trying%20to%20change%20home%20page%20banner%20image%20programmatically.%20You%20can%20use%20PnP%20Powershell%20to%20do%20that.%20Follow%20below%20steps%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20Connect%20your%20site%20using%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BConnect-PnPOnline%20-Url%20%24siteUrl%20-Credential%20%24credential%3C%2FP%3E%3CP%3E2.%20Get%20Client%20Side%20Page%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%24myHomePage%20%3D%26nbsp%3BGet-PnPClientSidePage%20-Identity%26nbsp%3BHome.aspx%3C%2FP%3E%3CP%3E3.%20Set%20custom%20page%20header%3A%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%24%3CSPAN%3EmyHomePage%3C%2FSPAN%3E.SetCustomPageHeader('%3CSERVER%20relative%3D%22%22%20image%3D%22%22%20url%3D%22%22%3E')%3C%2FSERVER%3E%3C%2FP%3E%3CP%3E4.%20Save%20the%20page%3A%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%24myHomePage.Save()%3C%2FP%3E%3CP%3E5.%20Publish%3A%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%24myHome.Publish()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20it%20helped.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-292257%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PowerShell%20to%20change%20page%20banner%20image%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-292257%22%20slang%3D%22en-US%22%3E%3CP%3EFYI%2C%20while%20not%20exactly%20what%20you%20are%20looking%20for%2C%20there%20are%20some%20new%20features%20rolling%20out%20that%20you%20may%20find%20helpful%2C%20see%3C%2FP%3E%3CDIV%20class%3D%22font-largeplus%20mc-msg-cl%20f-pad-top-5px%22%3EUpdated%20feature%3A%20we're%20rolling%20out%20new%20SharePoint%20Online%20site%20branding%20and%20navigation%20features%3C%2FDIV%3E%3CDIV%20class%3D%22font-medium%20mc-lbl-clr%20f-pad-top-5px%22%3E%3CDIV%3EMC165552%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EPublished%20On%20%3A%20November%2019%2C%202018%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
Blair24
Contributor

Hi Folks,

Currently have a automatic site creation tool up and running. I know using the PnP engine no content will be included in the template, but is there any way on the newly created site on the main home page (Modern Page) I can change the banner image using PowerShell to reference an image stored somewhere else?

Thanks!

3 Replies
Highlighted

FYI, while not exactly what you are looking for, there are some new features rolling out that you may find helpful, see

Updated feature: we're rolling out new SharePoint Online site branding and navigation features
MC165552
 
Published On : November 19, 2018
Highlighted
Solution

Blair,

I believe you are trying to change home page banner image programmatically. You can use PnP Powershell to do that. Follow below steps:

 

1. Connect your site using
     Connect-PnPOnline -Url $siteUrl -Credential $credential

2. Get Client Side Page
    $myHomePage = Get-PnPClientSidePage -Identity Home.aspx

3. Set custom page header:
   $myHomePage.SetCustomPageHeader('<Server relative Image URL>')

4. Save the page:
     $myHomePage.Save()

5. Publish:
     $myHome.Publish()

 

 

Let me know if it helped.

Highlighted

Hi Rahul,

 

Thanks for the response.

Dropped the Publishing from the script and worked.

 

Cheers!

Related Conversations
Issue scroll pages
Marco Mangiante in Discussions on
12 Replies
A problem with the Zoom level of a Tab
Tavory in Discussions on
9 Replies
Centering Pages in Modern Experience
yammy in SharePoint on
3 Replies
Changing the banner notification text
MattH1 in Microsoft Teams on
0 Replies