Get-PnPWebPart - how to get the web parts in the same order it is used in the page

59 Views Asked by At

I am using pnp library to retrieve the Webparts used in the Sharepoint page using this

Get-PnPWebPart -ServerRelativePageUrl "path-to-files/test.aspx"

But the order in which the webpart is included in the page is different in the result I am getting from the above.

How can I retrieve the webparts in the same order it is included in the page?

1

There are 1 best solutions below

0
Martin Iszac On

See: https://learn.microsoft.com/en-us/answers/questions/194481/sharepoint-online-get-list-of-webparts-using-power

Try Get-PnPClientSidePage:

$page = Get-PnPClientSidePage -Identity "Home.aspx"
$webParts = $page.Controls
foreach ($webpart in $webparts) {
    Write-Host "WebPart Id" $webpart.InstanceId
    Write-Host "Title" $webpart.Title
}

Try this and let me know if it helps.