Skip to content

[BUG] Set-PnPWebPartProperty does not change/add ContentLink for Page Viewer web part on classic page in SPO #5241

@shruti-naik-genmills

Description

@shruti-naik-genmills

Raised as advised by Microsoft support for this PnP behavior

Environment

  • SharePoint: SharePoint Online (modern site, classic page)
  • Page type: Classic web part page (/SitePages/Home.aspx) in a modern team site
  • Web part: Classic Page Viewer web part (Microsoft.SharePoint.Client.WebParts.WebPart, UI title "Quick Links")
  • PnP module: SharePointPnPPowerShellOnline 3.29.2101.0
  • Script host: Windows PowerShell 5.1

Scenario

We have a provisioning tool that creates project workspaces in SharePoint Online from a template site.

  • The template site is modern.
  • The Home page of each SharePoint (/SitePages/Home.aspx) is a classic page with classic web parts already added.
  • One of these web parts is a Page Viewer web part, titled "Quick Links", whose URL we need to update after the workspace is created.

The goal is to update the Page Viewer web part’s URL programmatically.

What we do

  1. Connect with PnP:
    Connect-PnPOnline -Url $SiteUrl -Credentials $Credential

  2. Resolve the page URL:
    $web = Get-PnPWeb
    $QuickLinkUrl = ($web.ServerRelativeUrl.TrimEnd('/')) + "/SitePages/Home.aspx"

  3. Ensure the page is checked out:
    Set-PnPFileCheckedOut -Url $QuickLinkUrl -ErrorAction SilentlyContinue

  4. Get the Page Viewer web part by title:
    $quickLinkWebPart = Get-PnPWebPart -ServerRelativePageUrl $QuickLinkUrl |
    Where-Object { $_.WebPart.Title -eq "Quick Links" } |
    Select-Object -First 1

  5. Dump properties:
    $props = Get-PnPWebPartProperty -ServerRelativePageUrl $QuickLinkUrl -Identity $quickLinkWebPart.Id
    $props | Format-List

This shows (among other properties):
Key : ContentLink
Value : https://Links.aspx?PID=220
Key : SourceType
Value : 4

  1. Try to update ContentLink:
    $ContentLinkValue = " https://Links.aspx?PID=210"

Set-PnPWebPartProperty
-ServerRelativePageUrl $QuickLinkUrl
-Identity $quickLinkWebPart.Id
-Key "ContentLink"
-Value $ContentLinkValue

  1. Re-fetch after the update:
    $testQuickLinkWebPart = Get-PnPWebPart -ServerRelativePageUrl $QuickLinkUrl |
    Where-Object { $_.WebPart.Title -eq "Quick Links" } |
    Select-Object -First 1

$testProps = Get-PnPWebPartProperty -ServerRelativePageUrl $QuickLinkUrl -Identity $testQuickLinkWebPart.Id
$testProps.ContentLink

Actual result

  • Set-PnPWebPartProperty does not throw when using -Key "ContentLink" (it only throws if we use -Key "Link", which is expected since that key does not exist).
  • After the call, Get-PnPWebPartProperty still returns the old URL in ContentLink, for example:

Current ContentLink (before): https://Links.aspx?PID=220
Current ContentLink (after) : https://Links.aspx?PID=220

  • The Page Viewer web part in the UI also continues to show the old URL.

So:

  • The property exists (ContentLink is clearly present and readable).
  • The cmdlet is not persisting the change to that property.

Additional details

  • The web part type reported by Get-PnPWebPart is:
    Web Part Type: Microsoft.SharePoint.Client.WebParts.WebPart
    Title : Quick Links
    Description : Displays another Web page on this Web page. The other Web page is presented in an IFrame.
    ContentLink : https://Links.aspx?PID=220
    SourceType : 4

  • The classic Page Viewer web part’s URL property is indeed ContentLink in server-side APIs; using Link fails with:

    Set-PnPWebPartProperty : The Link property does not exist.

  • The page is checked out and then checked in (major) after the update attempt.

Expected behavior

Set-PnPWebPartProperty should:

  • Persist the new ContentLink value for a classic Page Viewer web part on a classic page in SharePoint Online, when the property is clearly present in Get-PnPWebPartProperty.
  • After calling the cmdlet, a fresh Get-PnPWebPartProperty and the UI should both reflect the new URL.

Request

Could you please:

  • Confirm whether this is a known limitation/bug with Set-PnPWebPartProperty for classic Page Viewer web parts on SPO?
  • Suggest the recommended approach to reliably update ContentLink in this scenario?
  • If it’s a bug, consider fixing Set-PnPWebPartProperty so that it correctly persists ContentLink for Page Viewer web parts on classic pages in SharePoint Online.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions