Skip to main content
1 of 3
Luke
  • 13
  • 4

Trying to write a PnP Power shell script to update Highlighted Content WP within a page

I am trying to build a pnp powershell script that will update Highlighted Content webpart on a Modern Sharepoint Online page from Grid View to List view. I am using Convertfrom-Json and Convertto-json. Everything looks to work for the script but when I go and refresh the Sharepoint Page, it appears blank under that webpart. The plan is to eventually update all site pages containing HC webparts from Grid to List view.

$page= Get-PnPClientSidePage -Identity "TEST.aspx" $webpart = $page.Controls | ? {$_.InstanceId -eq ""} $WebpartJson= $webpart.PropertiesJson $webpartobj = ConvertFrom-Json -InputObject $webpartJson #$LayoutID= $Webpartobj.layoutId -eq "Card" IF($webpartobj.layoutId -eq "Card") { $webpartobj.layoutId = "List"} $webpartJson = ConvertTo-Json $webpartobj -Compress $webpart.PropertiesJson = $webpartJson $page.Save() $page.Publish()

Luke
  • 13
  • 4