Tramite la libreria PnP PowerShell è possibile accedere alle WebPart contenute in una pagina modern di SharePoint Online

PowerShell

Connect-PnPOnline -Url https://tenantName.sharepoint.com/ -UseWebLogin

$page = Get-PnPClientSidePage -Identity home.aspx
le WebPart sono contenute nella proprietà Controls

PowerShell

$page.Controls

Text

InstanceId                           Type              Title                         Section Column Position Properties Json
----------                           ----              -----                         ------- ------ -------- ----------
523f72f4-b9f9-4ff9-acd3-720cec7674e6 ClientSideWebPart Hero                          1       1      1        {"layou...
a93e2f18-1921-4e8c-9481-0ca4d8ff3690 ClientSideWebPart Image                         2       1      1        {"image...
073dd52d-9afa-48b7-b941-9029ecb8d27d ClientSideText                                  2       1      2
3c3acc5f-432c-4b7b-a6b3-0426a6dad5cf ClientSideWebPart Notizie                       2       1      3        {"showC...
25c26266-dac3-4346-97fb-4e581546fd58 ClientSideWebPart Eventi                        2       1      4        {"selec...
a715338c-fcb6-4ae0-8752-ffe99f7349a6 ClientSideWebPart Microsoft PowerApps (Preview) 2       1      5        {"power...
f078392e-7eed-43fc-93b2-92dda89bac3c ClientSideWebPart Contenuto evidenziato         2       1      6        {"query...
827b43f0-884e-4e84-a25a-a27032357605 ClientSideWebPart Collegamenti rapidi           2       1      7        {"items...
e836535d-fc72-4c20-9329-6eb50e4f84c2 ClientSideWebPart Persone                       2       1      8        {"perso...
3563e997-d7d4-4c70-8475-d558493006b4 ClientSideWebPart List                          2       1      9        {"isDoc...
la configurazione della singola WebPart è contenuta nella proprietà PropertiesJson come stringa JSON

PowerShell

# prima WebPart
$wp = $page.Controls[1]
$wp.PropertiesJson

JSON

{
   "imageSourceType":2,
   "captionText":"",
   "altText":"",
   "overlayText":"",
   "fileName":"",
   "siteId":"3e4c0ebf-a884-4666-a117-2a5d3ccace4a",
   "webId":"206abe16-8e4c-4883-8161-bbc06ecf94be",
   "listId":"31d61ab2-e0da-4942-9c03-5a6b9e7cc81b",
   "uniqueId":"{472F7042-5AF3-4DB3-8494-510B8D66F3D3}",
   "imgWidth":2560,
   "imgHeight":1707,
   "alignment":"Center",
   "fixAspectRatio":false,
   "isOverlayTextEnabled":true
}
Tags:
SharePoint Online77 PowerShell201
Potrebbe interessarti anche: