import Global from '../../_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# entra group member add

Adds members to a Microsoft Entra group

## Usage

```sh
m365 entra group member add [options]
```

## Options

```md definition-list
`-i, --groupId [groupId]`
: The ID of the Microsoft Entra group. Specify `groupId` or `groupName` but not both.

`-n, --groupName [groupName]`
: The display name of the Microsoft Entra group. Specify `groupId` or `groupName` but not both.
`--userIds [userIds]`
: Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify either `userIds`,`userNames`, `subgroupIds`, or `subgroupNames` but not multiple.

`--userNames [userNames]`
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `userIds`,`userNames`, `subgroupIds`, or `subgroupNames` but not multiple.

`--subgroupIds [subgroupIds]`
: Comma-separated list of Microsoft Entra group IDs to add. Specify either `userIds`,`userNames`, `subgroupIds`, or `subgroupNames` but not multiple.

`--subgroupNames [subgroupNames]`
: Comma-separated list of Microsoft Entra group titles to add. Specify either `userIds`,`userNames`, `subgroupIds`, or `subgroupNames` but not multiple.

`-r, --role <role>`
: The role to be assigned to the new users. Valid values: `Owner`, `Member`.
```

<Global />

## Permissions
<Tabs>
  <TabItem value="Delegated">

  | Resource        | Permissions               |
  |-----------------|---------------------------|
  | Microsoft Graph | GroupMember.ReadWrite.All |

  </TabItem>
  <TabItem value="Application">

  | Resource        | Permissions               |
  |-----------------|---------------------------|
  | Microsoft Graph | GroupMember.ReadWrite.All |

  </TabItem>
</Tabs>

## Examples

Add a single member specified by ID as a member to a group specified by group name.

```sh
m365 entra group member add --groupName Developers --userIds 098b9f52-f48c-4401-819f-29c33794c3f5 --role Member
```

Add multiple members specified by ID as members to a group specified by ID.

```sh
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --userIds "098b9f52-f48c-4401-819f-29c33794c3f5,f1e06e31-3abf-4746-83c2-1513d71f38b8" --role Member
```

Add a single member specified by UPN as an owner to a group specified by group name.

```sh
m365 entra group member add --groupName Developers --userNames john.doe@contoso.com --role Owner
```

Adds multiple members specified by UPN as owners to a group specified by ID.

```sh
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --userNames "john.doe@contoso.com,adele.vance@contoso.com" --role Owner
```

Add multiple members (subgroups) specified by ID as members to a group specified by ID.

```sh
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --subgroupIds "098b9f52-f48c-4401-819f-29c33794c3f5,f1e06e31-3abf-4746-83c2-1513d71f38b8" --role Member
```

Adds multiple members (subgroups) specified by name as members to a group specified by ID.

```sh
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --subgroupNames "Developers,Human Resources" --role Member
```

## Response

The command won't return a response on success.
