Skip to content

Commit

Permalink
Adds 'entra group member remove' command. Closes #5472
Browse files Browse the repository at this point in the history
  • Loading branch information
milanholemans committed Sep 28, 2024
1 parent a781c51 commit 27a2dc4
Show file tree
Hide file tree
Showing 7 changed files with 684 additions and 4 deletions.
84 changes: 84 additions & 0 deletions docs/docs/cmd/entra/group/group-member-remove.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import Global from '/docs/cmd/_global.mdx';

# entra group member remove

Removes members from a Microsoft Entra group

## Usage

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

## Options

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

`-n, --groupDisplayName [groupDisplayName]`
: The display name of the Entra ID group. Specify `groupId` or `groupDisplayName` but not both.

`--ids [ids]`
: Entra ID IDs of users. You can also pass a comma-separated list of IDs. Specify either `ids` or `userNames` but not both.

`--userNames [userNames]`
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both.

`-r, --role [role]`
: The role to be removed from the users. Valid values: `Owner`, `Member`. Defaults to both.

`--suppressNotFound`
: Suppress errors when a user was not found in a group.

`-f, --force`
: Don't prompt for confirmation.
```

<Global />

## Remarks

:::tip

When you use the `suppressNotFound` option, the command will not return an error if a user is not found as either an owner or a member of the group.
This feature proves useful when you need to remove a user from a group, but you are uncertain whether the user holds the role of a member or an owner within that group.
Without using this option, you would need to manually verify the user's role in the group before proceeding with removal.

:::

## Examples

Remove a single user specified by ID as member from a group specified by display name

```sh
m365 entra group member remove --groupDisplayName Developers --ids 098b9f52-f48c-4401-819f-29c33794c3f5 --role Member
```

Remove multiple users specified by ID from a group specified by ID

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

Remove a single user specified by UPN as an owner from a group specified by display name

```sh
m365 entra group member remove --groupDisplayName Developers --userNames [email protected] --role Owner
```

Remove multiple users specified by UPN from a group specified by ID

```sh
m365 entra group member remove --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --userNames "[email protected],[email protected]"
```

Remove a single user specified by ID as owner and member of the group and suppress errors when the user was not found as owner or member

```sh
m365 entra group member remove --groupDisplayName Developers --ids 098b9f52-f48c-4401-819f-29c33794c3f5 --suppressNotFound
```

## Response

The command won't return a response on success.
2 changes: 1 addition & 1 deletion docs/docs/cmd/entra/group/group-user-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Global from '/docs/cmd/_global.mdx';

# entra group user add

Adds a user to a Microsoft Entra ID group
Adds users to a Microsoft Entra ID group

## Usage

Expand Down
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ const sidebars: SidebarsConfig = {
label: 'group set',
id: 'cmd/entra/group/group-set'
},
{
type: 'doc',
label: 'group member remove',
id: 'cmd/entra/group/group-member-remove'
},
{
type: 'doc',
label: 'group user add',
Expand Down
1 change: 1 addition & 0 deletions src/m365/entra/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
GROUP_ADD: `${prefix} group add`,
GROUP_GET: `${prefix} group get`,
GROUP_LIST: `${prefix} group list`,
GROUP_MEMBER_REMOVE: `${prefix} group member remove`,
GROUP_REMOVE: `${prefix} group remove`,
GROUP_SET: `${prefix} group set`,
GROUP_USER_ADD: `${prefix} group user add`,
Expand Down
Loading

0 comments on commit 27a2dc4

Please sign in to comment.