spo group member add
Add members to a SharePoint Group
Usage
m365 spo group member add [options]
Options
-u, --webUrl <webUrl>
URL of the site where the SharePoint group is available.
--groupId [groupId]
Id of the SharePoint Group to which the user needs to be added, specify either
groupId
orgroupName
.--groupName [groupName]
Name of the SharePoint Group to which the user needs to be added, specify either
groupId
orgroupName
.--userNames [userNames]
User's UPN (user principal name, eg. megan.bowen@contoso.com). If multiple users need to be added, they have to be comma-separated (e.g. megan.bowen@contoso.com,alex.wilber@contoso.com). Specify either
userIds
,userNames
,emails
,aadGroupIds
oraadGroupNames
.--emails [emails]
User's email (eg. megan.bowen@contoso.com). If multiple users need to be added, they have to be comma-separated (e.g. megan.bowen@contoso.com,alex.wilber@contoso.com). Specify either
userIds
,userNames
,emails
,aadGroupIds
oraadGroupNames
.--userIds [userIds]
The user Id of the user to add as a member. (Id of the site user, for example: 14) If multiple users need to be added, the Ids have to be comma-separated. Specify either
userIds
,userNames
,emails
,aadGroupIds
oraadGroupNames
.--aadGroupIds [aadGroupIds]
The object Id of the Azure AD group to add as a member. If multiple groups need to be added, the Ids have to be comma-separated. Specify either
userIds
,userNames
,emails
,aadGroupIds
oraadGroupNames
.--aadGroupNames [aadGroupNames]
The name of the Azure AD group to add as a member. If multiple groups need to be added, they have to be comma-separated. Specify either
userIds
,userNames
,emails
,aadGroupIds
oraadGroupNames
.
-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 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
.--verbose
Runs command with verbose logging.
--debug
Runs command with debug logging.
Remarks
For the userIds
, userNames
, emails
, aadGroupIds
or aadGroupNames
options you can specify multiple values by separating them with a comma. If one of the specified entries is not valid, the command will fail with an error message showing the list of invalid values.
Examples
Add a user with the userNames parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userNames "Alex.Wilber@contoso.com"
Add multiple users with the userNames parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userNames "Alex.Wilber@contoso.com, Adele.Vance@contoso.com"
Add a user with the emails parameter to a SharePoint group with the groupName parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupName "Contoso Site Owners" --emails "Alex.Wilber@contoso.com"
Add multiple users with the emails parameter to a SharePoint group with the groupName parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupName "Contoso Site Owners" --emails "Alex.Wilber@contoso.com, Adele.Vance@contoso.com"
Add a user with the userIds parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userIds 5
Add multiple users with the userIds parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userIds "5,12"
Add multiple users with the aadUserId parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --aadUserId "56ca9023-3449-4e98-a96a-69e81a6f4983,a96c1755-8aec-4f4d-955f-08504510dc56"
Add multiple users with the aadUserName parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --aadUserName "Azure group one, Azure group two"
Response
- JSON
- Text
- CSV
- Markdown
[
{
"AllowedRoles": [
0
],
"CurrentRole": 0,
"DisplayName": "John Doe",
"Email": "john.doe@contoso.onmicrosoft.com",
"InvitationLink": null,
"IsUserKnown": true,
"Message": null,
"Status": true,
"User": "i:0#.f|membership|john.doe@contoso.onmicrosoft.com"
}
]
DisplayName Email
----------- ---------------------------------
John Doe john.doe@contoso.onmicrosoft.com
DisplayName,Email
John Doe,john.doe@contoso.onmicrosoft.com
# spo group member add --webUrl "https://contoso.sharepoint.com" --groupId "5" --aadGroupIds "f2fb2f10-cfd2-4054-8ffd-64533657a5ab"
Date: 13/2/2023
## All Company Members
Property | Value
---------|-------
AllowedRoles | [0]
CurrentRole | 0
DisplayName | All Company Members
Email | allcompany@contoso.onmicrosoft.com
InvitationLink | null
IsUserKnown | true
Message | null
Status | true
User | c:0o.c\|federateddirectoryclaimprovider\|f2fb2f10-cfd2-4054-8ffd-64533657a5ab