Closed sohailmerchant closed 4 years ago
Hm I think Get-PnPWebPartProperty
(and Get-PnPWebPart
) are used to get classic web parts, not modern web parts. The "out of range" error indicates that there is no classic web part with the given ID, which is correct.
You can use Get-PnPClientSideComponent -Page $newpage -InstanceId $wp.InstanceId
to get the web part including it's properties.
@heinrich-ulbricht, Thanks. Get-PnPClientSideComponent is helpful but we don't have any Set- for this cmdlet.
I managed to resolve this by adding the title in the PropertiesJson
like "title":"Title of the WebPart"}
.
@heinrich-ulbricht, Thanks. Get-PnPClientSideComponent is helpful but we don't have any Set- for this cmdlet.
I managed to resolve this by adding the title in the
PropertiesJson
like"title":"Title of the WebPart"}
.
Can you please expound on this. I have been strugling to find a method to set a web part propery in sharepoint online with powershell. how did you add the Json components ( and which command did you add it to)
I am adding webpart on the modern page
Add-PnPClientSideWebPart -Page $newpage -DefaultWebPartType “People” -Section 2 -Column 2 -WebPartProperties @{title=”People”}
and later in the process setting the PropertiesJson like
Set-PnPClientSideWebPart -Page $newpage -Identity $wp.InstanceId -PropertiesJson '{"properties": {"layout":1,"persons":[{"id":"admin@tenant.onmicrosoft.com","upn":"","role":"admin@tenant.onmicrosoft.com","department":"","phone":"","sip":""}]}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"title":"","persons[0].name":"SharePointer","persons[0].email":"admin@tenant.onmicrosoft.com"},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}'
After setting the
PropertiesJson
the Title for the webpart get removed. I thought I could get theGet-PnPWebPartProperty -Identity $p.InstanceId[0]
and set it again butGet-PnPWebProperty
doesn't seem to be working.Expected behavior
I thought
Get-PnPWebPartProperty
would return aJsonProperties
of a webpart which can be set.Actual behavior
I get either "Get-PnPWebPartProperty : File Not Found." or "Get-PnPWebPartProperty : Specified argument was out of the range of valid values.". I have tried various combination of sites/pnpsite1/SitePages/TestPage7.aspx or TestPage7.aspx and /SitePages/TestPage7.aspx nothing seem to work.
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
How did you install the PnP-PowerShell Cmdlets?