-
-
Save ypcode/393dddae595f17078841b667f44e193d 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
#!/bin/bash | |
site=https://contoso.sharepoint.com/sites/site1 | |
pageName=AModernPage.aspx | |
webPartId=af660fc1-c09b-4c15-b093-2b74b047286b | |
choice1='Choice X' | |
choice2='Choice Z' | |
description='My "Super Awesome" WebPart'; | |
# Build the JSON including your dynamic values with printf | |
# For each argument that might be dynamic, we escape the double quotes " with \" | |
# Make sure not to ommit the surrounding back ticks and surrounding double quotes for each arguments | |
printf -v webPartPropsJson '`{"myChoices":["%s","%s"], "description":"%s"}`' "${choice1//\"/\\\"}" "${choice2//\"/\\\"}" "${description//\"/\\\"}" | |
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