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
-
Connect with PnP:
Connect-PnPOnline -Url $SiteUrl -Credentials $Credential
-
Resolve the page URL:
$web = Get-PnPWeb
$QuickLinkUrl = ($web.ServerRelativeUrl.TrimEnd('/')) + "/SitePages/Home.aspx"
-
Ensure the page is checked out:
Set-PnPFileCheckedOut -Url $QuickLinkUrl -ErrorAction SilentlyContinue
-
Get the Page Viewer web part by title:
$quickLinkWebPart = Get-PnPWebPart -ServerRelativePageUrl $QuickLinkUrl |
Where-Object { $_.WebPart.Title -eq "Quick Links" } |
Select-Object -First 1
-
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
- Try to update
ContentLink:
$ContentLinkValue = " https://Links.aspx?PID=210"
Set-PnPWebPartProperty
-ServerRelativePageUrl $QuickLinkUrl
-Identity $quickLinkWebPart.Id
-Key "ContentLink"
-Value $ContentLinkValue
- 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.
Raised as advised by Microsoft support for this PnP behavior
Environment
/SitePages/Home.aspx) in a modern team siteMicrosoft.SharePoint.Client.WebParts.WebPart, UI title "Quick Links")SharePointPnPPowerShellOnline3.29.2101.0Scenario
We have a provisioning tool that creates project workspaces in SharePoint Online from a template site.
/SitePages/Home.aspx) is a classic page with classic web parts already added.The goal is to update the Page Viewer web part’s URL programmatically.
What we do
Connect with PnP:
Connect-PnPOnline -Url $SiteUrl -Credentials $Credential
Resolve the page URL:
$web = Get-PnPWeb
$QuickLinkUrl = ($web.ServerRelativeUrl.TrimEnd('/')) + "/SitePages/Home.aspx"
Ensure the page is checked out:
Set-PnPFileCheckedOut -Url $QuickLinkUrl -ErrorAction SilentlyContinue
Get the Page Viewer web part by title:
$quickLinkWebPart = Get-PnPWebPart -ServerRelativePageUrl $QuickLinkUrl |
Where-Object { $_.WebPart.Title -eq "Quick Links" } |
Select-Object -First 1
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
ContentLink:$ContentLinkValue = " https://Links.aspx?PID=210"
Set-PnPWebPartProperty
-ServerRelativePageUrl $QuickLinkUrl
-Identity $quickLinkWebPart.Id
-Key "ContentLink"
-Value $ContentLinkValue
$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-PnPWebPartPropertydoes not throw when using-Key "ContentLink"(it only throws if we use-Key "Link", which is expected since that key does not exist).Get-PnPWebPartPropertystill returns the old URL inContentLink, for example:Current ContentLink (before): https://Links.aspx?PID=220
Current ContentLink (after) : https://Links.aspx?PID=220
So:
ContentLinkis clearly present and readable).Additional details
The web part type reported by
Get-PnPWebPartis: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
ContentLinkin server-side APIs; usingLinkfails with:The page is checked out and then checked in (major) after the update attempt.
Expected behavior
Set-PnPWebPartPropertyshould:ContentLinkvalue for a classic Page Viewer web part on a classic page in SharePoint Online, when the property is clearly present inGet-PnPWebPartProperty.Get-PnPWebPartPropertyand the UI should both reflect the new URL.Request
Could you please:
Set-PnPWebPartPropertyfor classic Page Viewer web parts on SPO?ContentLinkin this scenario?Set-PnPWebPartPropertyso that it correctly persistsContentLinkfor Page Viewer web parts on classic pages in SharePoint Online.