Skip to content

Instantly share code, notes, and snippets.

@ypcode
Created May 16, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ypcode/393dddae595f17078841b667f44e193d to your computer and use it in GitHub Desktop.
Save ypcode/393dddae595f17078841b667f44e193d to your computer and use it in GitHub Desktop.
#!/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