-
-
Save ypcode/fbdf3445f4fcf7f7398c48ba70c1493a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$site = "https://contoso.sharepoint.com/sites/site1" | |
$pageName = "AModernPage.aspx" | |
$webPartId = "af660fc1-c09b-4c15-b093-2b74b047286b" | |
$choice1 = "Choice 1" | |
$choice2 = "Choice 2" | |
# Put all the WebPart properties in a PowerShell hashtable | |
$webPartProps = @{ | |
myChoices = @($choice1, $choice2); | |
description = 'My "Awesome" WebPart'; | |
}; | |
# Build JSON string from PowerShell hashtable object | |
$webPartPropsJson = $webPartProps | ConvertTo-Json -Compress | |
# Make sure to add the backticks, double the JSON double-quotes and escape double quotes in properties'values | |
$webPartPropsJson = '`"{0}"`' -f $webPartPropsJson.Replace('\','\\').Replace('"', '""') | |
o365 spo page clientsidewebpart add -u $site -n $pageName --webPartId $webPartId --webPartProperties $webPartPropsJson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment