Skip to content

Commit

Permalink
Enhance entra m365group user set command. Closes #6224
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodecleyre authored and MathijsVerbeeck committed Oct 16, 2024
1 parent d48e589 commit 99e059a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
11 changes: 4 additions & 7 deletions docs/docs/cmd/entra/m365group/m365group-user-set.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ m365 entra m365group user set [options]
`--teamName [teamName]`
: The display name of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`-n, --userName [userName]`
: (deprecated) User's UPN (User Principal Name), e.g. johndoe@example.com.

`--ids [ids]`
: Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify only one of the following `userName`, `ids` or `userNames`.
: Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify only one of the following `ids` or `userNames`.

`--userNames [userNames]`
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify only one of the following `userName`, `ids` or `userNames`.
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify only one of the following `ids` or `userNames`.

`-r, --role <role>`
: Role to set for the given user in the specified Microsoft 365 Group or Microsoft Teams team. Allowed values: `Owner`, `Member`
Expand All @@ -49,7 +46,7 @@ The command will return an error if the user already has the specified role in t
Promote a single user to Owner of the given Microsoft 365 Group

```sh
m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' --userName 'anne.matthews@contoso.onmicrosoft.com' --role Owner
m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com' --role Owner
```

Promote multiple users specified by the userNames parameter to Owner of the given Microsoft 365 Group
Expand All @@ -67,7 +64,7 @@ m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' -
Demote a single user from Owner to Member in the given Microsoft 365 Group

```sh
m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' --userName 'anne.matthews@contoso.onmicrosoft.com' --role Member
m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com' --role Member
```

Demote multiple users specified by the userNames parameter from Owner to Member of the given Microsoft Teams team
Expand Down
10 changes: 9 additions & 1 deletion docs/docs/v10-upgrade-guidance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The deprecated Guest value was removed from the `role` option in the [aad m365gr

#### What action do I need to take?

Please, check the documentation of the aad m365group user list](./cmd/entra/m365group/m365group-user-list.mdx) command to see the updated ``role` option and adjust your scripts accordingly.
Please, check the documentation of the [aad m365group user list](./cmd/entra/m365group/m365group-user-list.mdx) command to see the updated ``role` option and adjust your scripts accordingly.

#### Aligned options with naming convention

Expand Down Expand Up @@ -149,6 +149,14 @@ As part of the renaming of Azure AD to Microsoft Entra ID, we have removed the `

Please, check if your scripts use any of the `aad` commands and if so update it to `entra` commands.

### Removed deprecated option `username` from `entra m365group user set` command.

The deprecated option `username` was removed from the [entra m365group user set](./cmd/entra/m365group/m365group-user-set.mdx) command.

#### What action do I need to take?

Please, check the documentation of the [entra m365group user set](./cmd/entra/m365group/m365group-user-set.mdx) command to see the updated `username` option and adjust your scripts accordingly.

## SharePoint

### Updated `spo site appcatalog remove` options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ describe(commands.M365GROUP_USER_SET, () => {
sinonUtil.restore(entraGroup.isUnifiedGroup);
sinon.stub(entraGroup, 'isUnifiedGroup').resolves(false);

await assert.rejects(command.action(logger, { options: { groupId: groupId, userName: 'anne.matthews@contoso.onmicrosoft.com' } } as any),
await assert.rejects(command.action(logger, { options: { groupId: groupId, userNames: userUpns.join(',') } } as any),
new CommandError(`Specified group with id '${groupId}' is not a Microsoft 365 group.`));
});
});
15 changes: 3 additions & 12 deletions src/m365/entra/commands/m365group/m365group-user-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface CommandArgs {
}

interface Options extends GlobalOptions {
userName?: string;
ids?: string;
userNames?: string;
groupId?: string;
Expand Down Expand Up @@ -59,9 +58,6 @@ class EntraM365GroupUserSetCommand extends GraphCommand {

#initOptions(): void {
this.options.unshift(
{
option: '-n, --userName [userName]'
},
{
option: '--ids [ids]'
},
Expand Down Expand Up @@ -123,28 +119,23 @@ class EntraM365GroupUserSetCommand extends GraphCommand {

#initOptionSets(): void {
this.optionSets.push({ options: ['groupId', 'groupName', 'teamId', 'teamName'] });
this.optionSets.push({ options: ['userName', 'ids', 'userNames'] });
this.optionSets.push({ options: ['ids', 'userNames'] });
}

#initTypes(): void {
this.types.string.push('userName', 'ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
this.types.string.push('ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
}

public async commandAction(logger: Logger, args: CommandArgs): Promise<void> {
if (args.options.userName) {
await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
}

try {
const userNames = args.options.userNames || args.options.userName;
const groupId: string = await this.getGroupId(logger, args);
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);

if (!isUnifiedGroup) {
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
}

const userIds: string[] = await this.getUserIds(logger, args.options.ids, userNames);
const userIds: string[] = await this.getUserIds(logger, args.options.ids, args.options.userNames);

// we can't simply switch the role
// first add users to the new role
Expand Down

0 comments on commit 99e059a

Please sign in to comment.