Skip to content

spo page clientsidewebpart add

Adds a client-side web part to a modern page

Usage

m365 spo page clientsidewebpart add [options]

Options

-u, --webUrl <webUrl>
URL of the site where the page to add the web part to is located.
-n, --pageName <pageName>
Name of the page to which add the web part.
--standardWebPart [standardWebPart]
Name of the standard web part to add (see the possible values below). Specify either standardWebPart or webPartId but not both.
--webPartId [webPartId]
ID of the custom web part to add. Specify either standardWebPart or webPartId but not both.
--webPartProperties [webPartProperties]
JSON string with web part properties to set on the web part. Specify either webPartProperties or webPartData but not both.
--webPartData [webPartData]
JSON string with web part data as retrieved from the web part maintenance mode. Specify either webPartProperties or webPartData but not both.
--section [section]
Number of the section to which the web part should be added (1 or higher).
--column [column]
Number of the column in which the web part should be added (1 or higher).
--order [order]
Order of the web part in the column.
-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,md. 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.

To add a standard web part to the page, specify one of the following values: ContentRollup, BingMap, ContentEmbed, DocumentEmbed, Image, ImageGallery, LinkPreview, NewsFeed, NewsReel, PowerBIReportEmbed, QuickChart, SiteActivity, VideoEmbed, YammerEmbed, Events, GroupCalendar, Hero, List, PageTitle, People, QuickLinks, CustomMessageRegion, Divider, MicrosoftForms, Spacer.

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

Add the standard Bing Map web part to a modern page in the first available location on the page

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap

Add the standard Bing Map web part to a modern page in the third column of the second section

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --section 2 --column 3

Add a custom web part to the modern page

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --webPartId 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1

Add the standard Bing Map web part with the specific properties to a modern page

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart BingMap --webPartProperties '{"Title":"Foo location"}'

Add the standard Image web part with the preconfigured image

m365 spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart Image --webPartData '{ "dataVersion": "1.8", "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"captionText":""},"imageSources":{"imageSource":"/sites/team-a/SiteAssets/work-life-balance.png"},"links":{}}, "properties": {"imageSourceType":2,"altText":"a group of people on a beach","overlayText":"Work life balance","fileName":"48146-OFF12_Justice_01.png","siteId":"27664b85-067d-4be9-a7d7-89b2e804d09f","webId":"a7664b85-067d-4be9-a7d7-89b2e804d09f","listId":"37664b85-067d-4be9-a7d7-89b2e804d09f","uniqueId":"67664b85-067d-4be9-a7d7-89b2e804d09f","imgWidth":650,"imgHeight":433,"fixAspectRatio":false,"isOverlayTextEnabled":true}}'

Response

The command won't return a response on success.