Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 'entra group member remove' command #5844

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/cmd/entra/group/group-member-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 member add

Adds a member to a Microsoft Entra ID group
Adds members to a Microsoft Entra group

## Usage

Expand Down
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.
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@ const sidebars: SidebarsConfig = {
label: 'group member list',
id: 'cmd/entra/group/group-member-list'
},
{
type: 'doc',
label: 'group member remove',
id: 'cmd/entra/group/group-member-remove'
},
{
type: 'doc',
label: 'group member 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 @@ -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_MEMBER_ADD: `${prefix} group member add`,
Expand Down
2 changes: 1 addition & 1 deletion src/m365/entra/commands/group/group-member-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EntraGroupMemberAddCommand extends GraphCommand {
}

public get description(): string {
return 'Adds a member to a Microsoft Entra ID group';
return 'Adds members to a Microsoft Entra group';
}

constructor() {
Expand Down
Loading