spo commandset add¶
Add a ListView Command Set to a site.
Usage¶
m365 spo commandset add [options]
Options¶
-t, --title <title>
- The title of the ListView Command Set
-u, --webUrl <webUrl>
- The site to add the ListView Command Set.
-l, --listType <listType>
- The list or library type to register the Command Set on. Allowed values
List
,Library
orSitePages
. -i, --clientSideComponentId <clientSideComponentId>
- The Client Side Component Id (GUID) of the ListView Command Set.
--clientSideComponentProperties [clientSideComponentProperties]
- The Client Side Component properties of the ListView Command Set.
-s, --scope [scope]
- Scope of the ListView Command Set. Allowed values:
Site
,Web
. Defaults toWeb
. --location [location]
- The location of the ListView Command Set. Allowed values
ContextMenu
,CommandBar
orBoth
. Defaults toCommandBar
. -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 isfull
. --query [query]
- JMESPath query string. See http://jmespath.org/ for more information and examples
-o, --output [output]
- Output type.
json,text,csv,md
. Defaultjson
--verbose
- Runs command with verbose logging
--debug
- Runs command with debug logging
Remarks¶
Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for command options that have JSON, XML, or JavaScript values because the command shell treats quotes differently. For example, this is how a ListView Command Set can be created from the Windows cmd.exe:
m365 spo commandset add --webUrl https://contoso.sharepoint.com/sites/test --title "CLI Commandset" --location "ContextMenu" --listType "List" --clientSideComponentId b41916e7-e69d-467f-b37f-ff8ecf8f99f2 --clientSideComponentProperties '{\"testMessage\":\"Test message\"}'
Note, how the clientSideComponentProperties option (-p) has escaped double quotes '{\"testMessage\":\"Test message\"}'
compared to execution from bash '{"testMessage":"Test message"}'
.
Escaping JSON in PowerShell
When using the --clientSideComponentProperties
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¶
Adds a ListView Command Set to lists on the sales site.
m365 spo commandset add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --listType List --webUrl https://contoso.sharepoint.com/sites/sales
Adds a ListView Command Set to lists on the sales site with some properties.
m365 spo commandset add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --clientSideComponentProperties '{ "someProperty": "Some value" }' --listType List --webUrl https://contoso.sharepoint.com/sites/sales
Response¶
{
"ClientSideComponentId": "b206e130-1a5b-4ae7-86a7-4f91c9924d0a",
"ClientSideComponentProperties": "",
"CommandUIExtension": null,
"Description": null,
"Group": null,
"HostProperties": "",
"Id": "680ccc51-7ddf-4dda-8696-fc606480cc3f",
"ImageUrl": null,
"Location": "ClientSideExtension.ListViewCommandSet.CommandBar",
"Name": null,
"RegistrationId": "100",
"RegistrationType": 0,
"Rights": {
"High": "0",
"Low": "0"
},
"Scope": 2,
"ScriptBlock": null,
"ScriptSrc": null,
"Sequence": 0,
"Title": "CLI Commandset",
"Url": null,
"VersionOfUserCustomAction": "16.0.1.0"
}
ClientSideComponentId : b206e130-1a5b-4ae7-86a7-4f91c9924d0a
ClientSideComponentProperties:
CommandUIExtension : null
Description : null
Group : null
HostProperties :
Id : 680ccc51-7ddf-4dda-8696-fc606480cc3f
ImageUrl : null
Location : ClientSideExtension.ListViewCommandSet.CommandBar
Name : null
RegistrationId : 100
RegistrationType : 0
Rights : {"High":"0","Low":"0"}
Scope : 2
ScriptBlock : null
ScriptSrc : null
Sequence : 0
Title : CLI Commandset
Url : null
VersionOfUserCustomAction : 16.0.1.0
ClientSideComponentId,ClientSideComponentProperties,CommandUIExtension,Description,Group,HostProperties,Id,ImageUrl,Location,Name,RegistrationId,RegistrationType,Rights,Scope,ScriptBlock,ScriptSrc,Sequence,Title,Url,VersionOfUserCustomAction
b206e130-1a5b-4ae7-86a7-4f91c9924d0a,,,,,,680ccc51-7ddf-4dda-8696-fc606480cc3f,,ClientSideExtension.ListViewCommandSet.CommandBar,,100,0,"{""High"":""0"",""Low"":""0""}",2,,,0,CLI Commandset,,16.0.1.0
# spo commandset add --title "CLI Commandset" --webUrl "https://contoso.sharepoint.com" --clientSideComponentId "b206e130-1a5b-4ae7-86a7-4f91c9924d0a" --listType "List" --scope "Site"
Date: 10/2/2023
## CLI Commandset (680ccc51-7ddf-4dda-8696-fc606480cc3f)
Property | Value
---------|-------
ClientSideComponentId | b206e130-1a5b-4ae7-86a7-4f91c9924d0a
ClientSideComponentProperties |
CommandUIExtension | null
Description | null
Group | null
HostProperties |
Id | 680ccc51-7ddf-4dda-8696-fc606480cc3f
ImageUrl | null
Location | ClientSideExtension.ListViewCommandSet.CommandBar
Name | null
RegistrationId | 100
RegistrationType | 0
Rights | {"High":"0","Low":"0"}
Scope | 2
ScriptBlock | null
ScriptSrc | null
Sequence | 0
Title | CLI Commandset
Url | null
VersionOfUserCustomAction | 16.0.1.0