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
,entraGroupIds
orentraGroupNames
.--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
,entraGroupIds
orentraGroupNames
.--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
,entraGroupIds
orentraGroupNames
.--entraGroupIds [entraGroupIds]
The object Id of the Entra 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
,entraGroupIds
orentraGroupNames
.--entraGroupNames [entraGroupNames]
The name of the Entra group to add as a member. If multiple groups need to be added, they have to be comma-separated. Specify either
userIds
,userNames
,emails
,entraGroupIds
orentraGroupNames
.
-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
, entraGroupIds
, or entraGroupNames
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 entraGroupIds parameter to a SharePoint group with the groupId parameter.
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --entraGroupIds "f2fb2f10-cfd2-4054-8ffd-64533657a5ab,3e86049e-89e6-4c27-bccb-d7549f0bbd06"
Add multiple users with the entraGroupNames parameter to a SharePoint group with the groupId parameter.
m365 spo group member add --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --entraGroupNames "Azure group one, Azure group two"
Response
- JSON
- Text
- CSV
- Markdown
[
{
"Id": 11,
"IsHiddenInUI": false,
"LoginName": "i:0#.f|membership|adelev@contoso.onmicrosoft.com",
"Title": "Adele Vance",
"PrincipalType": 1,
"Email": "Adele.Vance@contoso.onmicrosoft.com",
"Expiration": "",
"IsEmailAuthenticationGuestUser": false,
"IsShareByEmailGuestUser": false,
"IsSiteAdmin": false,
"UserId": {
"NameId": "10032001f5ac2029",
"NameIdIssuer": "urn:federation:microsoftonline"
},
"UserPrincipalName": "adelev@contoso.onmicrosoft.com"
}
]
Title UserPrincipalName
----------- -------------------------------------
Adele Vance Adele.Vance@contoso.onmicrosoft.com
Id,IsHiddenInUI,LoginName,Title,PrincipalType,Email,Expiration,IsEmailAuthenticationGuestUser,IsShareByEmailGuestUser,IsSiteAdmin,UserPrincipalName
11,,i:0#.f|membership|adelev@contoso.onmicrosoft.com,Adele Vance,1,Adele.Vance@contoso.onmicrosoft.com,,,,,adelev@contoso.onmicrosoft.com
# spo group member add --webUrl "https://contoso.sharepoint.com/sites/Marketing" --groupId "5" --userNames "AdeleV@contoso.onmicrosoft.com"
Date: 10/07/2024
## Adele Vance (11)
Property | Value
---------|-------
Id | 11
IsHiddenInUI | false
LoginName | i:0#.f\|membership\|adelev@contoso.onmicrosoft.com
Title | Adele Vance
PrincipalType | 1
Email | Adele.Vance@contoso.onmicrosoft.com
Expiration |
IsEmailAuthenticationGuestUser | false
IsShareByEmailGuestUser | false
IsSiteAdmin | false
UserPrincipalName | adelev@contoso.onmicrosoft.com