Skip to content

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 webPartProperties or webPartData but not both
--webPartProperties [webPartProperties]
JSON string with web part data as retrieved from the web part maintenance mode. Specify webPartProperties or webPartData but not both
-h, --help [help]
Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is full.
--query [query]
JMESPath query string. See http://jmespath.org/ for more information and examples
-o, --output [output]
Output type. json,text,csv. Default json
--verbose
Runs command with verbose logging
--debug
Runs 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.

Escaping JSON in PowerShell

When using the --webPartProperties option 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.

Examples

Update web part data for the control with ID 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1 placed on a modern page with name home.aspx

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 with ID 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1 placed on a modern page with name home.aspx

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"}'