spo page control set
Updates web part data or properties of a control on a modern page
Usage
m365 spo page control set [options]
Options
-i, --id <id>ID of the control to update properties of.
-n, --pageName <pageName>Name of the page where the control is located.
-u, --webUrl <webUrl>URL of the site where the page is located.
--webPartData [webPartData]JSON string with web part data as retrieved from the web part maintenance mode. Specify either
innerHtml,webPartPropertiesorwebPartDatabut not more than one.--webPartProperties [webPartProperties]JSON string with web part data as retrieved from the web part maintenance mode. Specify either
innerHtml,webPartPropertiesorwebPartDatabut not more than one.--innerHtml [innerHtml]Inner HTML to set on the control. Specify either
innerHtml,webPartPropertiesorwebPartDatabut not more than one.
-h, --help [help]Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are
options,examples,remarks,permissions,response,full. Default isoptions.--query [query]JMESPath query string. See http://jmespath.org/ for more information and examples.
-o, --output [output]Output type.
json,text,csv,md,none. Defaultjson.--verboseRuns command with verbose logging.
--debugRuns command with debug logging.
Remarks
If the specified pageName doesn't refer to an existing modern page, you will get a File doesn't exists error.
When using the webPartProperties or webPartData options it's possible to enter a JSON string. In PowerShell 5 to 7.2 specific escaping rules apply due to an issue. Remember that you can also use file tokens instead.
When using webPartProperties or webPartData, only the properties you specify will be updated. Any properties not included in the JSON string will remain unchanged.
Examples
Update web part data for the control, placed on a modern page
m365 spo page control set --id 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1 --webUrl https://contoso.sharepoint.com/sites/team-a --pageName home.aspx --webPartData '{"title":"New WP Title","properties": {"description": "New description"}}'
Update web part properties for the control, placed on a modern page
m365 spo page control set --id 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1 --webUrl https://contoso.sharepoint.com/sites/team-a --pageName home.aspx --webPartProperties '{"description": "New description"}'
Update the text of a text web part
m365 spo page control set --id 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1 --webUrl https://contoso.sharepoint.com/sites/team-a --pageName home.aspx --innerHtml '<p>This text was updated by <a href="https://aka.ms/cli-m365">CLI for Microsoft 365</a></p>'
Response
The command won't return a response on success.