Skip to content

Commit

Permalink
Adds 'entra group user remove' command. Closes #5472
Browse files Browse the repository at this point in the history
  • Loading branch information
milanholemans committed May 20, 2024
1 parent 884c943 commit 0633f4b
Show file tree
Hide file tree
Showing 7 changed files with 684 additions and 4 deletions.
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
84 changes: 84 additions & 0 deletions docs/docs/cmd/entra/group/group-user-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 user remove

Removes users from a Microsoft Entra ID group

## Usage

```sh
m365 entra group user 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 user 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 user 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 user remove --groupDisplayName Developers --userNames [email protected] --role Owner
```

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

```sh
m365 entra group user 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 user remove --groupDisplayName Developers --ids 098b9f52-f48c-4401-819f-29c33794c3f5 --suppressNotFound
```

## Response

The command won't return a response on success.
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ const sidebars: SidebarsConfig = {
label: 'group user list',
id: 'cmd/entra/group/group-user-list'
},
{
type: 'doc',
label: 'group user remove',
id: 'cmd/entra/group/group-user-remove'
},
{
type: 'doc',
label: 'group user set',
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 @@ -41,6 +41,7 @@ export default {
GROUP_REMOVE: `${prefix} group remove`,
GROUP_USER_ADD: `${prefix} group user add`,
GROUP_USER_LIST: `${prefix} group user list`,
GROUP_USER_REMOVE: `${prefix} group user remove`,
GROUP_USER_SET: `${prefix} group user set`,
GROUPSETTING_ADD: `${prefix} groupsetting add`,
GROUPSETTING_GET: `${prefix} groupsetting get`,
Expand Down
Loading

0 comments on commit 0633f4b

Please sign in to comment.