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
--userName [userName]
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
userId
,userName
,email
,aadGroupId
oraadGroupName
--email [email]
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
userId
,userName
,email
,aadGroupId
oraadGroupName
--userId [userId]
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
userId
,userName
,email
,aadGroupId
oraadGroupName
--aadGroupId [aadGroupId]
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
userId
,userName
,email
,aadGroupId
oraadGroupName
--aadGroupName [aadGroupName]
The name of the Azure AD group to add as a member. Specify either
userId
,userName
,email
,aadGroupId
oraadGroupName
-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
For the userId
, userName
, email
, aadGroupId
or aadGroupName
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 userName parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userName "Alex.Wilber@contoso.com"
Add multiple users with the userName parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userName "Alex.Wilber@contoso.com, Adele.Vance@contoso.com"
Add a user with the email 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" --email "Alex.Wilber@contoso.com"
Add multiple users with the email 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" --email "Alex.Wilber@contoso.com, Adele.Vance@contoso.com"
Add a user with the userId parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userId 5
Add multiple users with the userId parameter to a SharePoint group with the groupId parameter
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userId "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" --aadGroupId "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