Pnp-powershell: SharePoint Online modern page bannerimageurl set but not set issue

Created on 25 Sep 2017  路  3Comments  路  Source: pnp/PnP-PowerShell

I think I鈥檝e discovered a bug/issue with setting the BannerImageUrl for SharePoint online Modern Pages.

I expect that when I run the following the banner for page ID2 will change

Set-PnPListItem -List "SitePages" -Id 2 -Values @{"BannerImageUrl" = " https://contoso.sharepoint.com/sites/mycomsite3/bannerimages/bread-braid-tedster-sml.jpg";}

When I check using the following code the page ID2 reports it鈥檚 banner has been changed.

$items = Get-PnPListItem -List "SitePages" -Fields ID,Title,BannerImageUrl
    $items | %{new-object PSObject -Property @{Id=$_["ID"];Title=$_["Title"];BannerImageUrl=$_["BannerImageUrl"].Url}} | select ID,Title,BannerImageUrl

BUT when I actually view the page in the browser the banner of page ID2 has not changed.

My goal is to use PNP cmdlets to set the banner image on new pages, to an image I鈥檝e already uploaded to a library within the site.

Cmdlet versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     2.18.17... SharePointPnPPowerShell2016         {Add-PnPContentType, Add-PnPContentTypeToDocumentSet,
    Directory: C:\Users\<user>\AppData\Local\Apps\SharePointPnPPowerShellOnline\Modules
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     2.18.17... SharePointPnPPowerShellOnline       {Add-PnPClientSidePage, Add-PnPClientSidePageSection,
    Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     2.18.17... SharePointPnPPowerShellOnline       {Add-PnPClientSidePage, Add-PnPClientSidePageSection,
Binary     2.17.17... SharePointPnPPowerShellOnline       {Add-PnPContentType, Add-PnPContentTypeToDocumentSet,

Cmdlet install

  • I think I鈥檝e used the install-module method.

Please tell me what I'm doing wrong when I set the BannerImageUrl.
Your experience and knowledge greatly accepted.

Most helpful comment

I'm also having issues trying to set the BannerImageUrl. I've tried various things, including:

  • using different URL types (absolute, site relative, URL based on getpreview.ashx?params etc.)
  • using a single URL vs. the dual URL/comma-separated form

It seems that the LayoutWebpartsContent property is also relevant here (i.e. things will work if some modification to this is performed). Through some reverse-engineering of this property (including a lot of XML/JSON parsing, I've been able to get things working under certain conditions) - however, we need a reliable, simple abstraction onto this.

PnP team - can you help at all? Even if you can tell us what is needed before your method arrives, that would be great :) @jansenbe @VesaJuvonen

All 3 comments

I've checked using SharePoint designer and when I run code like the following

Set-PnPListItem -List "SitePages" -Id 29 -Values @{"BannerImageUrl" = "";}

The code within the ASPX page is modified to

<mso:BannerImageUrl msdt:dt="string"></mso:BannerImageUrl>

But the page when viewed in the borwser doesn't show no bannerimage.

Same if I copy the <mso:BannerImageUrl value from another page and use set-PnPListItem to insert it into a page ID29 . The ASPX page changes but the page doesn't display the new banner image. e.g.

Set-PnPListItem -List "SitePages" -Id 29 -Values @{"BannerImageUrl" = "https://brighterdays.sharepoint.com/_layouts/15/getpreview.ashx?guidSite=7b7f24b2-a8f8-47b9-ba32-99d7d24ea2bf&guidWeb=a6b51390-845d-4345-95c7-15b16d9048f9&guidFile=0b5854ac-fc5e-41d4-a772-a9fa0eae2b80, https://brighterdays.sharepoint.com/_layouts/15/getpreview.ashx?guidSite=7b7f24b2-a8f8-47b9-ba32-99d7d24ea2bf&guidWeb=a6b51390-845d-4345-95c7-15b16d9048f9&guidFile=0b5854ac-fc5e-41d4-a772-a9fa0eae2b80";}

Hope this helps

I'm also having issues trying to set the BannerImageUrl. I've tried various things, including:

  • using different URL types (absolute, site relative, URL based on getpreview.ashx?params etc.)
  • using a single URL vs. the dual URL/comma-separated form

It seems that the LayoutWebpartsContent property is also relevant here (i.e. things will work if some modification to this is performed). Through some reverse-engineering of this property (including a lot of XML/JSON parsing, I've been able to get things working under certain conditions) - however, we need a reliable, simple abstraction onto this.

PnP team - can you help at all? Even if you can tell us what is needed before your method arrives, that would be great :) @jansenbe @VesaJuvonen

This issue was moved to SharePoint/PnP-Sites-Core#1464

Was this page helpful?
0 / 5 - 0 ratings