From 93357091c19f5834f1b145daea60e7f5d3f287ed Mon Sep 17 00:00:00 2001 From: Martin Machacek Date: Sat, 24 Aug 2024 22:15:33 +0200 Subject: [PATCH] All entra m365group commands should accept displayName option --- .../m365group/m365group-conversation-list.mdx | 8 ++++---- .../m365group-conversation-post-list.mdx | 10 +++++----- .../m365group/m365group-recyclebinitem-list.mdx | 6 +++--- .../cmd/entra/m365group/m365group-user-list.mdx | 10 +++++----- .../entra/m365group/m365group-user-remove.mdx | 10 +++++----- .../m365group-conversation-list.spec.ts | 4 ++-- .../m365group/m365group-conversation-list.ts | 14 +++++++------- .../m365group-conversation-post-list.spec.ts | 10 +++++----- .../m365group-conversation-post-list.ts | 10 +++++----- .../commands/m365group/m365group-user-add.ts | 13 +------------ .../m365group/m365group-user-list.spec.ts | 8 ++++---- .../commands/m365group/m365group-user-list.ts | 12 ++++++------ .../m365group/m365group-user-remove.spec.ts | 4 ++-- .../commands/m365group/m365group-user-remove.ts | 16 ++++++++-------- .../commands/m365group/m365group-user-set.ts | 10 ---------- 15 files changed, 62 insertions(+), 83 deletions(-) diff --git a/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx b/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx index 2aebf3452d7..cad668f4e77 100644 --- a/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx @@ -22,10 +22,10 @@ m365 aad m365group conversation list [options] ```md definition-list `-i, --groupId [groupId]` -: The ID of the Microsoft 365 Group. Specify either `groupId` or `groupDisplayName`, but not both. +: The ID of the Microsoft 365 Group. Specify either `groupId` or `groupName`, but not both. -`-n, --groupDisplayName [groupDisplayName]` -: Display name of the Microsoft 365 Group. Specify either `groupId` or `groupDisplayName`, but not both. +`-n, --groupName [groupName]` +: Display name of the Microsoft 365 Group. Specify either `groupId` or `groupName`, but not both. ``` @@ -41,7 +41,7 @@ m365 entra m365group conversation list --groupId '00000000-0000-0000-0000-000000 Lists conversations for the Microsoft 365 group specified by displayName. ```sh -m365 entra m365group conversation list --groupDisplayName Finance +m365 entra m365group conversation list --groupName Finance ``` ## Response diff --git a/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx b/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx index 539fef72ea2..f24890ed5a8 100644 --- a/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx @@ -22,10 +22,10 @@ m365 aad m365group conversation post list [options] ```md definition-list `-i, --groupId [groupId]` -: The Id of the Microsoft 365 Group. You can specify the groupId or groupDisplayName, but not both. +: The Id of the Microsoft 365 Group. You can specify the groupId or groupName, but not both. -`-d, --groupDisplayName [groupDisplayName]` -: The Displayname of the Microsoft 365 Group. You can specify the groupId or groupDisplayName, but not both. +`-d, --groupName [groupName]` +: The Displayname of the Microsoft 365 Group. You can specify the groupId or groupName, but not both. `-t, --threadId ` : The ID of the thread to retrieve details for @@ -41,10 +41,10 @@ Lists the posts of the specific conversation of Microsoft 365 group by groupId m365 entra m365group conversation post list --groupId '00000000-0000-0000-0000-000000000000' --threadId 'AAQkADkwN2Q2NDg1LWQ3ZGYtNDViZi1iNGRiLTVhYjJmN2Q5NDkxZQAQAOnRAfDf71lIvrdK85FAn5E=' ``` -Lists the posts of the specific conversation of Microsoft 365 group by groupDisplayName +Lists the posts of the specific conversation of Microsoft 365 group by groupName ```sh -m365 entra m365group conversation post list --groupDisplayName 'MyGroup' --threadId 'AAQkADkwN2Q2NDg1LWQ3ZGYtNDViZi1iNGRiLTVhYjJmN2Q5NDkxZQAQAOnRAfDf71lIvrdK85FAn5E=' +m365 entra m365group conversation post list --groupName 'MyGroup' --threadId 'AAQkADkwN2Q2NDg1LWQ3ZGYtNDViZi1iNGRiLTVhYjJmN2Q5NDkxZQAQAOnRAfDf71lIvrdK85FAn5E=' ``` ## Response diff --git a/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx b/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx index 6173c72d673..1c7014d6371 100644 --- a/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx @@ -21,7 +21,7 @@ m365 aad m365group recyclebinitem list [options] ## Options ```md definition-list -`-d, --groupDisplayName [groupDisplayName]` +`-d, --groupName [groupName]` : Lists groups with DisplayName starting with the specified value `-m, --groupMailNickname [groupMailNickname]` @@ -41,7 +41,7 @@ m365 entra m365group recyclebinitem list List deleted Microsoft 365 Groups with display name starting with _Project_ ```sh -m365 entra m365group recyclebinitem list --groupDisplayName Project +m365 entra m365group recyclebinitem list --groupName Project ``` List deleted Microsoft 365 Groups mail nick name starting with _team_ @@ -53,7 +53,7 @@ m365 entra m365group recyclebinitem list --groupMailNickname team List deleted Microsoft 365 Groups mail nick name starting with _team_ and with display name starting with _Project_ ```sh -m365 entra m365group recyclebinitem list --groupMailNickname team --groupDisplayName Project +m365 entra m365group recyclebinitem list --groupMailNickname team --groupName Project ``` ## Response diff --git a/docs/docs/cmd/entra/m365group/m365group-user-list.mdx b/docs/docs/cmd/entra/m365group/m365group-user-list.mdx index 06126c04fd8..a5a39df8b98 100644 --- a/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-user-list.mdx @@ -22,10 +22,10 @@ m365 aad m365group user list [options] ```md definition-list `-i, --groupId [groupId]` -: The ID of the Microsoft 365 group. Specify `groupId` or `groupDisplayName` but not both. +: The ID of the Microsoft 365 group. Specify `groupId` or `groupName` but not both. -`-n, --groupDisplayName [groupDisplayName]` -: The display name of the Microsoft 365 group. Specify `groupId` or `groupDisplayName` but not both. +`-n, --groupName [groupName]` +: The display name of the Microsoft 365 group. Specify `groupId` or `groupName` but not both. `-r, --role [role]` : Filter the results to only users with the given role. Allowed values: `Owner`, `Member`, or (Deprecated) `Guest`. @@ -54,7 +54,7 @@ m365 entra m365group user list --groupId '00000000-0000-0000-0000-000000000000' List all owners from Microsoft 365 group specified by display name. ```sh -m365 entra m365group user list --groupDisplayName Developers --role Owner +m365 entra m365group user list --groupName Developers --role Owner ``` List specific properties for all group users from a group specified by ID. @@ -66,7 +66,7 @@ m365 entra m365group user list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe -- List all group members that are guest users. ```sh -m365 entra m365group user list --groupDisplayName Developers --filter "userType eq 'Guest'" +m365 entra m365group user list --groupName Developers --filter "userType eq 'Guest'" ``` ## Response diff --git a/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx b/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx index 1d007c6c7d5..1df7130b682 100644 --- a/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx +++ b/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx @@ -24,13 +24,13 @@ m365 teams user remove [options] ```md definition-list `-i, --groupId [groupId]` -: The ID of the Microsoft 365 Group from which to remove the user. Specify either `groupId`, `groupDisplayName` or `teamId`, but not multiple. +: The ID of the Microsoft 365 Group from which to remove the user. Specify either `groupId`, `groupName` or `teamId`, but not multiple. -`--groupDisplayName [groupDisplayName]` -: Display name of the Microsoft 365 Group for which to remove the user. Specify either `groupId`, `groupDisplayName` or `teamId`, but not multiple. +`--groupName [groupName]` +: Display name of the Microsoft 365 Group for which to remove the user. Specify either `groupId`, `groupName` or `teamId`, but not multiple. `--teamId [teamId]` -: The ID of the Microsoft Teams team from which to remove the user. Specify either `groupId`, `groupDisplayName` or `teamId`, but not multiple. +: The ID of the Microsoft Teams team from which to remove the user. Specify either `groupId`, `groupName` or `teamId`, but not multiple. `-n, --userName ` : User's UPN (user principal name), eg. `johndoe@example.com` @@ -56,7 +56,7 @@ m365 entra m365group user remove --groupId '00000000-0000-0000-0000-000000000000 Removes user from the specified Microsoft 365 Group without confirmation ```sh -m365 entra m365group user remove --groupDisplayName Finance --userName 'anne.matthews@contoso.onmicrosoft.com' --force +m365 entra m365group user remove --groupName Finance --userName 'anne.matthews@contoso.onmicrosoft.com' --force ``` Removes user from the specified Microsoft Teams team diff --git a/src/m365/entra/commands/m365group/m365group-conversation-list.spec.ts b/src/m365/entra/commands/m365group/m365group-conversation-list.spec.ts index c6dc1b57c33..c86850368bf 100644 --- a/src/m365/entra/commands/m365group/m365group-conversation-list.spec.ts +++ b/src/m365/entra/commands/m365group/m365group-conversation-list.spec.ts @@ -132,7 +132,7 @@ describe(commands.M365GROUP_CONVERSATION_LIST, () => { )); }); - it('Retrieve conversations for the group specified by groupDisplayName in the tenant (verbose)', async () => { + it('Retrieve conversations for the group specified by groupName in the tenant (verbose)', async () => { sinon.stub(request, 'get').callsFake(async (opts) => { if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/conversations`) { return jsonOutput; @@ -142,7 +142,7 @@ describe(commands.M365GROUP_CONVERSATION_LIST, () => { await command.action(logger, { options: { - verbose: true, groupDisplayName: "Finance" + verbose: true, groupName: "Finance" } }); assert(loggerLogSpy.calledWith( diff --git a/src/m365/entra/commands/m365group/m365group-conversation-list.ts b/src/m365/entra/commands/m365group/m365group-conversation-list.ts index f06fb43afa9..5e441d7eb7e 100644 --- a/src/m365/entra/commands/m365group/m365group-conversation-list.ts +++ b/src/m365/entra/commands/m365group/m365group-conversation-list.ts @@ -14,7 +14,7 @@ interface CommandArgs { interface Options extends GlobalOptions { groupId?: string; - groupDisplayName?: string; + groupName?: string; } class EntraM365GroupConversationListCommand extends GraphCommand { @@ -49,7 +49,7 @@ class EntraM365GroupConversationListCommand extends GraphCommand { option: '-i, --groupId [groupId]' }, { - option: '-n, --groupDisplayName [groupDisplayName]' + option: '-n, --groupName [groupName]' } ); } @@ -67,25 +67,25 @@ class EntraM365GroupConversationListCommand extends GraphCommand { } #initOptionSets(): void { - this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }); + this.optionSets.push({ options: ['groupId', 'groupName'] }); } #initTypes(): void { - this.types.string.push('groupId', 'groupDisplayName'); + this.types.string.push('groupId', 'groupName'); } public async commandAction(logger: Logger, args: CommandArgs): Promise { await this.showDeprecationWarning(logger, aadCommands.M365GROUP_CONVERSATION_LIST, commands.M365GROUP_CONVERSATION_LIST); if (this.verbose) { - await logger.logToStderr(`Retrieving conversations for Microsoft 365 Group: ${args.options.groupId || args.options.groupDisplayName}...`); + await logger.logToStderr(`Retrieving conversations for Microsoft 365 Group: ${args.options.groupId || args.options.groupName}...`); } try { let groupId = args.options.groupId; - if (args.options.groupDisplayName) { - groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupDisplayName); + if (args.options.groupName) { + groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupName); } const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId!); diff --git a/src/m365/entra/commands/m365group/m365group-conversation-post-list.spec.ts b/src/m365/entra/commands/m365group/m365group-conversation-post-list.spec.ts index 08c66bf6bc3..994f414c56f 100644 --- a/src/m365/entra/commands/m365group/m365group-conversation-post-list.spec.ts +++ b/src/m365/entra/commands/m365group/m365group-conversation-post-list.spec.ts @@ -135,7 +135,7 @@ describe(commands.M365GROUP_CONVERSATION_POST_LIST, () => { it('defines correct properties for the default output', () => { assert.deepStrictEqual(command.defaultProperties(), ['receivedDateTime', 'id']); }); - it('fails validation if groupId and groupDisplayName specified', async () => { + it('fails validation if groupId and groupName specified', async () => { sinon.stub(cli, 'getSettingWithDefaultValue').callsFake((settingName, defaultValue) => { if (settingName === settingsNames.prompt) { return false; @@ -144,10 +144,10 @@ describe(commands.M365GROUP_CONVERSATION_POST_LIST, () => { return defaultValue; }); - const actual = await command.validate({ options: { groupId: '1caf7dcd-7e83-4c3a-94f7-932a1299c844', groupDisplayName: 'MyGroup', threadId: '123' } }, commandInfo); + const actual = await command.validate({ options: { groupId: '1caf7dcd-7e83-4c3a-94f7-932a1299c844', groupName: 'MyGroup', threadId: '123' } }, commandInfo); assert.notStrictEqual(actual, true); }); - it('fails validation if neither groupId nor groupDisplayName specified', async () => { + it('fails validation if neither groupId nor groupName specified', async () => { sinon.stub(cli, 'getSettingWithDefaultValue').callsFake((settingName, defaultValue) => { if (settingName === settingsNames.prompt) { return false; @@ -187,7 +187,7 @@ describe(commands.M365GROUP_CONVERSATION_POST_LIST, () => { jsonOutput.value )); }); - it('Retrieve posts for the specified conversation threadId of m365 group groupDisplayName in the tenant (verbose)', async () => { + it('Retrieve posts for the specified conversation threadId of m365 group groupName in the tenant (verbose)', async () => { sinon.stub(request, 'get').callsFake(async (opts) => { if ((opts.url as string).indexOf('/groups?$filter=displayName') > -1) { return { @@ -208,7 +208,7 @@ describe(commands.M365GROUP_CONVERSATION_POST_LIST, () => { await command.action(logger, { options: { verbose: true, - groupDisplayName: "MyGroup", + groupName: "MyGroup", threadId: "AAQkADkwN2Q2NDg1LWQ3ZGYtNDViZi1iNGRiLTVhYjJmN2Q5NDkxZQAQAOnRAfDf71lIvrdK85FAn5E=" } }); diff --git a/src/m365/entra/commands/m365group/m365group-conversation-post-list.ts b/src/m365/entra/commands/m365group/m365group-conversation-post-list.ts index 3c680103a59..a6baa453ed8 100644 --- a/src/m365/entra/commands/m365group/m365group-conversation-post-list.ts +++ b/src/m365/entra/commands/m365group/m365group-conversation-post-list.ts @@ -15,7 +15,7 @@ interface CommandArgs { interface Options extends GlobalOptions { groupId?: string; - groupDisplayName?: string; + groupName?: string; threadId: string; } @@ -45,7 +45,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand { this.telemetry.push((args: CommandArgs) => { Object.assign(this.telemetryProperties, { groupId: typeof args.options.groupId !== 'undefined', - groupDisplayName: typeof args.options.groupDisplayName !== 'undefined' + groupName: typeof args.options.groupName !== 'undefined' }); }); } @@ -56,7 +56,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand { option: '-i, --groupId [groupId]' }, { - option: '-d, --groupDisplayName [groupDisplayName]' + option: '-d, --groupName [groupName]' }, { option: '-t, --threadId ' @@ -77,7 +77,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand { } #initOptionSets(): void { - this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }); + this.optionSets.push({ options: ['groupId', 'groupName'] }); } public defaultProperties(): string[] | undefined { @@ -108,7 +108,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand { return formatting.encodeQueryParameter(args.options.groupId); } - const group = await entraGroup.getGroupByDisplayName(args.options.groupDisplayName!); + const group = await entraGroup.getGroupByDisplayName(args.options.groupName!); return group.id!; } } diff --git a/src/m365/entra/commands/m365group/m365group-user-add.ts b/src/m365/entra/commands/m365group/m365group-user-add.ts index 8475b277f12..dd2f9b10b41 100644 --- a/src/m365/entra/commands/m365group/m365group-user-add.ts +++ b/src/m365/entra/commands/m365group/m365group-user-add.ts @@ -23,7 +23,6 @@ interface Options extends GlobalOptions { teamId?: string; teamName?: string; role?: string; - groupDisplayName?: string; } class EntraM365GroupUserAddCommand extends GraphCommand { @@ -151,18 +150,8 @@ class EntraM365GroupUserAddCommand extends GraphCommand { const providedGroupId: string = await this.getGroupId(logger, args); const isUnifiedGroup = await entraGroup.isUnifiedGroup(providedGroupId); - let groupId = args.options.groupId; - - if (args.options.groupDisplayName) { - groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupDisplayName); - } - else if (args.options.teamId) { - groupId = args.options.teamId; - } - const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId!); - if (!isUnifiedGroup) { - throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`); + throw Error(`Specified group with id '${providedGroupId}' is not a Microsoft 365 group.`); } const userIds: string[] = await this.getUserIds(logger, args.options.ids, userNames); diff --git a/src/m365/entra/commands/m365group/m365group-user-list.spec.ts b/src/m365/entra/commands/m365group/m365group-user-list.spec.ts index 9e9a6844d0d..1805ef2dac3 100644 --- a/src/m365/entra/commands/m365group/m365group-user-list.spec.ts +++ b/src/m365/entra/commands/m365group/m365group-user-list.spec.ts @@ -200,7 +200,7 @@ describe(commands.M365GROUP_USER_LIST, () => { throw 'Invalid request'; }); - await command.action(logger, { options: { verbose: true, groupDisplayName: "CLI Test Group" } }); + await command.action(logger, { options: { verbose: true, groupName: "CLI Test Group" } }); assert(loggerLogSpy.calledOnceWithExactly([ { "id": "00000000-0000-0000-0000-000000000000", @@ -449,12 +449,12 @@ describe(commands.M365GROUP_USER_LIST, () => { }); it('throws error when the group by name is not a unified group', async () => { - const groupDisplayName = 'CLI Test Group'; + const groupName = 'CLI Test Group'; sinonUtil.restore(entraGroup.isUnifiedGroup); sinon.stub(entraGroup, 'isUnifiedGroup').resolves(false); - await assert.rejects(command.action(logger, { options: { verbose: true, groupDisplayName: groupDisplayName } } as any), - new CommandError(`Specified group '${groupDisplayName}' is not a Microsoft 365 group.`)); + await assert.rejects(command.action(logger, { options: { verbose: true, groupName: groupName } } as any), + new CommandError(`Specified group '${groupName}' is not a Microsoft 365 group.`)); }); }); diff --git a/src/m365/entra/commands/m365group/m365group-user-list.ts b/src/m365/entra/commands/m365group/m365group-user-list.ts index e5ff5859fca..69d4606dcf6 100644 --- a/src/m365/entra/commands/m365group/m365group-user-list.ts +++ b/src/m365/entra/commands/m365group/m365group-user-list.ts @@ -16,7 +16,7 @@ interface CommandArgs { interface Options extends GlobalOptions { filter?: string; groupId?: string; - groupDisplayName?: string; + groupName?: string; properties?: string; role?: string; } @@ -51,7 +51,7 @@ class EntraM365GroupUserListCommand extends GraphCommand { this.telemetry.push((args: CommandArgs) => { Object.assign(this.telemetryProperties, { groupId: typeof args.options.groupId !== 'undefined', - groupDisplayName: typeof args.options.groupDisplayName !== 'undefined', + groupName: typeof args.options.groupName !== 'undefined', role: typeof args.options.role !== 'undefined', properties: typeof args.options.properties !== 'undefined', filter: typeof args.options.filter !== 'undefined' @@ -65,7 +65,7 @@ class EntraM365GroupUserListCommand extends GraphCommand { option: "-i, --groupId [groupId]" }, { - option: "-n, --groupDisplayName [groupDisplayName]" + option: "-n, --groupName [groupName]" }, { option: "-r, --role [type]", @@ -83,7 +83,7 @@ class EntraM365GroupUserListCommand extends GraphCommand { #initOptionSets(): void { this.optionSets.push( { - options: ['groupId', 'groupDisplayName'] + options: ['groupId', 'groupName'] } ); } @@ -118,7 +118,7 @@ class EntraM365GroupUserListCommand extends GraphCommand { const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId); if (!isUnifiedGroup) { - throw Error(`Specified group '${args.options.groupId || args.options.groupDisplayName}' is not a Microsoft 365 group.`); + throw Error(`Specified group '${args.options.groupId || args.options.groupName}' is not a Microsoft 365 group.`); } let users: ExtendedUser[] = []; @@ -162,7 +162,7 @@ class EntraM365GroupUserListCommand extends GraphCommand { await logger.logToStderr('Retrieving Group Id...'); } - return await entraGroup.getGroupIdByDisplayName(options.groupDisplayName!); + return await entraGroup.getGroupIdByDisplayName(options.groupName!); } private async getUsers(options: Options, role: string, groupId: string, logger: Logger): Promise { diff --git a/src/m365/entra/commands/m365group/m365group-user-remove.spec.ts b/src/m365/entra/commands/m365group/m365group-user-remove.spec.ts index 554c3e62aeb..549f4ad778c 100644 --- a/src/m365/entra/commands/m365group/m365group-user-remove.spec.ts +++ b/src/m365/entra/commands/m365group/m365group-user-remove.spec.ts @@ -232,7 +232,7 @@ describe(commands.M365GROUP_USER_REMOVE, () => { assert(memberDeleteCallIssued); }); - it('removes the specified owner from owners and members endpoint of the Microsoft 365 Group specified by groupDisplayName with accepted prompt', async () => { + it('removes the specified owner from owners and members endpoint of the Microsoft 365 Group specified by groupName with accepted prompt', async () => { let memberDeleteCallIssued = false; sinon.stub(request, 'get').callsFake(async (opts) => { @@ -277,7 +277,7 @@ describe(commands.M365GROUP_USER_REMOVE, () => { sinonUtil.restore(cli.promptForConfirmation); sinon.stub(cli, 'promptForConfirmation').resolves(true); - await command.action(logger, { options: { groupDisplayName: "Finance", userName: "anne.matthews@contoso.onmicrosoft.com" } }); + await command.action(logger, { options: { groupName: "Finance", userName: "anne.matthews@contoso.onmicrosoft.com" } }); assert(memberDeleteCallIssued); }); diff --git a/src/m365/entra/commands/m365group/m365group-user-remove.ts b/src/m365/entra/commands/m365group/m365group-user-remove.ts index a507cfe5714..ba7b17c7e2c 100644 --- a/src/m365/entra/commands/m365group/m365group-user-remove.ts +++ b/src/m365/entra/commands/m365group/m365group-user-remove.ts @@ -21,7 +21,7 @@ interface UserResponse { interface Options extends GlobalOptions { teamId?: string; groupId?: string; - groupDisplayName?: string; + groupName?: string; userName: string; force?: boolean; } @@ -55,7 +55,7 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand { force: (!(!args.options.force)).toString(), teamId: typeof args.options.teamId !== 'undefined', groupId: typeof args.options.groupId !== 'undefined', - groupDisplayName: typeof args.options.groupDisplayName !== 'undefined' + groupName: typeof args.options.groupName !== 'undefined' }); }); } @@ -66,7 +66,7 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand { option: "-i, --groupId [groupId]" }, { - option: "--groupDisplayName [groupDisplayName]" + option: "--groupName [groupName]" }, { option: "--teamId [teamId]" @@ -97,24 +97,24 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand { } #initOptionSets(): void { - this.optionSets.push({ options: ['groupId', 'groupDisplayName', 'teamId'] }); + this.optionSets.push({ options: ['groupId', 'groupName', 'teamId'] }); } #initTypes(): void { - this.types.string.push('groupId', 'groupDisplayName', 'teamId'); + this.types.string.push('groupId', 'groupName', 'teamId'); } public async commandAction(logger: Logger, args: CommandArgs): Promise { await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_REMOVE, commands.M365GROUP_USER_REMOVE); if (this.verbose) { - await logger.logToStderr(`Removing user ${args.options.userName} for Microsoft 365 Group: ${args.options.groupId || args.options.groupDisplayName || args.options.teamId}...`); + await logger.logToStderr(`Removing user ${args.options.userName} for Microsoft 365 Group: ${args.options.groupId || args.options.groupName || args.options.teamId}...`); } let groupId = args.options.groupId; - if (args.options.groupDisplayName) { - groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupDisplayName); + if (args.options.groupName) { + groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupName); } else if (args.options.teamId) { groupId = args.options.teamId; diff --git a/src/m365/entra/commands/m365group/m365group-user-set.ts b/src/m365/entra/commands/m365group/m365group-user-set.ts index 23810770bfb..02a0d62efba 100644 --- a/src/m365/entra/commands/m365group/m365group-user-set.ts +++ b/src/m365/entra/commands/m365group/m365group-user-set.ts @@ -149,16 +149,6 @@ class EntraM365GroupUserSetCommand extends GraphCommand { const groupId: string = await this.getGroupId(logger, args); const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId); - let groupId = args.options.groupId; - - if (args.options.groupDisplayName) { - groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupDisplayName); - } - else if (args.options.teamId) { - groupId = args.options.teamId; - } - const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId!); - if (!isUnifiedGroup) { throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`); }