Add QuickLinks Webpart by using pnp powershell
-
14-02-2021 - |
Question
I'm trying to add quicklinks webpart with powershell. The webpart is created but the link is not displayed.
I managed to add many Web Parts using the minimum amount of Web Parts data, the json format complicates handling, but I am in trouble with the Quicklinks Web Part. Below is the code I tried using:
Add-PnPClientSideWebPart -Page $page -DefaultWebPartType "QuickLinks" -WebPartProperties @{title="QuickLinksTest";items=@(@{id=1;title="Google";sourceItem=@{url="https://www.google.com"};description="Description 1";altText="altText 1"})}
Can anyone help with this please?
Thank you.
Solution
I finally found the right minimum data to use to have the expected result:
Add-PnPClientSideWebPart -Page $page -DefaultWebPartType "QuickLinks" -WebPartProperties @{title="QuickLinks 2";items=@(@{sourceItem=@{url="https://www.google.com";itemType=2;fileExtension="";progId=""};title="Google";thumbnailType=3;id=2};@{sourceItem=@{url="https://www.youtube.com";itemType=2;fileExtension="";progId=""};title="Youtube";thumbnailType=3;id=1});hideWebPartWhenEmpty="true"}
this code can be improved to add and manage display options.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange