How to add a custom image banner to a header of a site using PnP PowerShell?

Githendra Perera 1 Reputation point
2022-06-15T09:06:43.88+00:00

Hi everyone !

I'm trying to add a custom banner image to my site header but I can't seem to get it working using powershell. I've read some docs such as :
https://pnp.github.io/powershell/cmdlets/Get-PnPWeb.html
https://pnp.github.io/powershell/cmdlets/Get-PnPWebHeader.html
https://pnp.github.io/powershell/cmdlets/Set-PnPWebHeader.html

This is what I found on other forums about this :

Connect-PnPOnline -Url https://XXX.sharepoint.com/sites/test4  
Set-PnPWebHeader -HeaderBackgroundImageUrl "https://XXX.sharepoint.com/sites/test4/Style Library/__extendedHeaderBackgroundImage__getsitelogo.jpg"  
Invoke-PnPQuery  

Can anyone help me?

Thanks,

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,608 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,791 Reputation points
    2022-06-16T07:31:30.147+00:00

    Hi GithendraPerera-1991,

    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()

    ----------------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.