From 99e059a16f68a911ba7cb4d7efde3893102b802a Mon Sep 17 00:00:00 2001 From: Nico De Cleyre Date: Mon, 26 Aug 2024 18:01:36 +0200 Subject: [PATCH] Enhance `entra m365group user set` command. Closes #6224 --- .../cmd/entra/m365group/m365group-user-set.mdx | 11 ++++------- docs/docs/v10-upgrade-guidance.mdx | 10 +++++++++- .../commands/m365group/m365group-user-set.spec.ts | 2 +- .../commands/m365group/m365group-user-set.ts | 15 +++------------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/docs/docs/cmd/entra/m365group/m365group-user-set.mdx b/docs/docs/cmd/entra/m365group/m365group-user-set.mdx index f2ac7cc1451..b5b60faf6b6 100644 --- a/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-user-set.mdx @@ -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 to set for the given user in the specified Microsoft 365 Group or Microsoft Teams team. Allowed values: `Owner`, `Member` @@ -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 @@ -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 diff --git a/docs/docs/v10-upgrade-guidance.mdx b/docs/docs/v10-upgrade-guidance.mdx index 1402e97ad85..a157e7c0367 100644 --- a/docs/docs/v10-upgrade-guidance.mdx +++ b/docs/docs/v10-upgrade-guidance.mdx @@ -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 @@ -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 diff --git a/src/m365/entra/commands/m365group/m365group-user-set.spec.ts b/src/m365/entra/commands/m365group/m365group-user-set.spec.ts index 0a2912c336d..75377fe0d57 100644 --- a/src/m365/entra/commands/m365group/m365group-user-set.spec.ts +++ b/src/m365/entra/commands/m365group/m365group-user-set.spec.ts @@ -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.`)); }); }); diff --git a/src/m365/entra/commands/m365group/m365group-user-set.ts b/src/m365/entra/commands/m365group/m365group-user-set.ts index be1d9e0d51f..063876dec42 100644 --- a/src/m365/entra/commands/m365group/m365group-user-set.ts +++ b/src/m365/entra/commands/m365group/m365group-user-set.ts @@ -13,7 +13,6 @@ interface CommandArgs { } interface Options extends GlobalOptions { - userName?: string; ids?: string; userNames?: string; groupId?: string; @@ -59,9 +58,6 @@ class EntraM365GroupUserSetCommand extends GraphCommand { #initOptions(): void { this.options.unshift( - { - option: '-n, --userName [userName]' - }, { option: '--ids [ids]' }, @@ -123,20 +119,15 @@ 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 { - 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); @@ -144,7 +135,7 @@ class EntraM365GroupUserSetCommand extends GraphCommand { 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