Skip to main content
deleted 46 characters in body
Source Link
Luke
  • 13
  • 4

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 "<InstanceID of Specific HC webpart>"}
$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()

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 "<InstanceID of Specific HC webpart>"}
$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()

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 "<InstanceID of Specific HC webpart>"}
$WebpartJson= $webpart.PropertiesJson
$webpartobj = ConvertFrom-Json -InputObject $webpartJson
IF($webpartobj.layoutId -eq "Card") {

    $webpartobj.layoutId = "List"

}
$webpartJson = ConvertTo-Json $webpartobj -Compress
$webpart.PropertiesJson = $webpartJson
$page.Save()
$page.Publish()
reformatted
Source Link
Asad Refai
  • 6k
  • 8
  • 35
  • 57

I am trying to build a pnp powershellPnp PowerShell script that will update Highlighted Content webpart on a Modern SharepointSharePoint Online page from Grid View to List view. 

I am using Convertfrom-JsonConvertfrom-Json and Convertto-jsonConvertto-json. 

Everything looks to work for the script but when I go and refresh the SharepointSharePoint 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()

$page= Get-PnPClientSidePage -Identity "TEST.aspx"
$webpart = $page.Controls | ? {$_.InstanceId -eq "<InstanceID of Specific HC webpart>"}
$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()

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

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 "<InstanceID of Specific HC webpart>"}
$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()
Source Link
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()