Specifically, I'm adding a Documents web part using PNP Powershell to a newly created modern page, and would like to set the size of the webpart as part of my script. My current code is

Add-PnPPageWebPart -Page $pageName -DefaultWebPartType List -Section 1 -Column 1 -WebPartProperties @{isDocumentLibrary="true";

I've tried adding a WebPartProperty of "size" with different options but that doesn't seem to work. I've tried using Get-PnPWebPartProperty to find the name of the size property but that always errors with "Specified argument was out of the range of valid values" even though I'm using the guid of the webpart (as far as I can tell).

1 Answer 1


I got the same issue with you when I use Get-PnPWebPartProperty command.

As a workaround, use following pnp powershell to retrieve the properties of document library web part in specific page:

$Page= "TestSitePage"
$Test = Get-PnPPageComponent -Page $Page -InstanceId $InstanceId 

And I found there is no size property of document web part, that's why we could not set the size of it via pnp powershell: enter image description here

  • The webpartHeightKey propery works instead, thanks for that! 1 = small, 2 = medium, 3 = large, but sadly there doesn't seem to be a value for Autosize, which is the one I need
    – Gerry
    Aug 27, 2021 at 19:05
  • If you find any reply helpful to you, you could mark it as answer.
    – Julie_MSFT
    Aug 30, 2021 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.