@pnp/cli-microsoft365 10.0.0-beta.da65889 → 10.0.0-beta.fd332f4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/appInsights.js +6 -4
- package/dist/m365/commands/login.js +2 -2
- package/dist/m365/commands/setup.js +1 -1
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-add.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-add.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-get.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-list.js +0 -5
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +0 -5
- package/dist/m365/entra/commands/app/app-add.js +0 -5
- package/dist/m365/entra/commands/app/app-get.js +0 -5
- package/dist/m365/entra/commands/app/app-list.js +0 -5
- package/dist/m365/entra/commands/app/app-permission-add.js +0 -5
- package/dist/m365/entra/commands/app/app-remove.js +0 -5
- package/dist/m365/entra/commands/app/app-role-add.js +0 -5
- package/dist/m365/entra/commands/app/app-role-list.js +0 -5
- package/dist/m365/entra/commands/app/app-role-remove.js +0 -5
- package/dist/m365/entra/commands/app/app-set.js +0 -5
- package/dist/m365/entra/commands/approleassignment/approleassignment-add.js +0 -5
- package/dist/m365/entra/commands/approleassignment/approleassignment-list.js +0 -5
- package/dist/m365/entra/commands/approleassignment/approleassignment-remove.js +0 -5
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +0 -5
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +0 -5
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +0 -5
- package/dist/m365/entra/commands/group/group-add.js +0 -4
- package/dist/m365/entra/commands/group/group-get.js +0 -5
- package/dist/m365/entra/commands/group/group-list.js +0 -5
- package/dist/m365/entra/commands/group/group-member-list.js +0 -5
- package/dist/m365/entra/commands/group/group-remove.js +0 -5
- package/dist/m365/entra/commands/groupsetting/groupsetting-add.js +0 -5
- package/dist/m365/entra/commands/groupsetting/groupsetting-get.js +0 -5
- package/dist/m365/entra/commands/groupsetting/groupsetting-list.js +0 -5
- package/dist/m365/entra/commands/groupsetting/groupsetting-remove.js +0 -5
- package/dist/m365/entra/commands/groupsetting/groupsetting-set.js +0 -5
- package/dist/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.js +0 -5
- package/dist/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-list.js +0 -5
- package/dist/m365/entra/commands/license/license-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-add.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-conversation-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-get.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-clear.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-remove.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-restore.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-remove.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-renew.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-report-activitycounts.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-report-activitydetail.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-report-activityfilecounts.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-report-activitygroupcounts.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-report-activitystorage.js +0 -4
- package/dist/m365/entra/commands/m365group/m365group-set.js +138 -73
- package/dist/m365/entra/commands/m365group/m365group-teamify.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +0 -6
- package/dist/m365/entra/commands/m365group/m365group-user-list.js +0 -5
- package/dist/m365/entra/commands/m365group/m365group-user-remove.js +84 -62
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +3 -15
- package/dist/m365/entra/commands/oauth2grant/oauth2grant-add.js +0 -5
- package/dist/m365/entra/commands/oauth2grant/oauth2grant-list.js +0 -5
- package/dist/m365/entra/commands/oauth2grant/oauth2grant-remove.js +0 -5
- package/dist/m365/entra/commands/oauth2grant/oauth2grant-set.js +0 -5
- package/dist/m365/entra/commands/policy/policy-list.js +0 -5
- package/dist/m365/entra/commands/siteclassification/siteclassification-disable.js +0 -5
- package/dist/m365/entra/commands/siteclassification/siteclassification-enable.js +0 -5
- package/dist/m365/entra/commands/siteclassification/siteclassification-get.js +0 -5
- package/dist/m365/entra/commands/siteclassification/siteclassification-set.js +0 -5
- package/dist/m365/entra/commands/user/user-add.js +0 -5
- package/dist/m365/entra/commands/user/user-get.js +0 -5
- package/dist/m365/entra/commands/user/user-guest-add.js +0 -5
- package/dist/m365/entra/commands/user/user-hibp.js +0 -5
- package/dist/m365/entra/commands/user/user-license-add.js +0 -5
- package/dist/m365/entra/commands/user/user-license-list.js +0 -5
- package/dist/m365/entra/commands/user/user-license-remove.js +0 -5
- package/dist/m365/entra/commands/user/user-list.js +0 -5
- package/dist/m365/entra/commands/user/user-password-validate.js +0 -5
- package/dist/m365/entra/commands/user/user-recyclebinitem-clear.js +0 -5
- package/dist/m365/entra/commands/user/user-recyclebinitem-list.js +0 -5
- package/dist/m365/entra/commands/user/user-recyclebinitem-remove.js +0 -5
- package/dist/m365/entra/commands/user/user-recyclebinitem-restore.js +0 -5
- package/dist/m365/entra/commands/user/user-registrationdetails-list.js +0 -4
- package/dist/m365/entra/commands/user/user-remove.js +0 -5
- package/dist/m365/entra/commands/user/user-set.js +0 -5
- package/dist/m365/entra/commands/user/user-signin-list.js +0 -5
- package/dist/m365/file/commands/file-move.js +4 -4
- package/dist/m365/spo/commands/file/file-copy.js +6 -6
- package/dist/m365/spo/commands/file/file-move.js +6 -6
- package/dist/m365/spo/commands/file/file-remove.js +7 -1
- package/dist/m365/spo/commands/folder/folder-copy.js +43 -35
- package/dist/m365/spo/commands/folder/folder-move.js +43 -35
- package/dist/m365/spo/commands/group/group-member-add.js +3 -23
- package/dist/m365/spo/commands/group/group-member-remove.js +1 -18
- package/dist/m365/spo/commands/list/list-remove.js +14 -4
- package/dist/m365/spo/commands/tenant/tenant-site-membership-list.js +118 -0
- package/dist/m365/spo/commands/user/user-ensure.js +1 -11
- package/dist/m365/spo/commands/userprofile/userprofile-get.js +1 -1
- package/dist/m365/spo/commands.js +1 -0
- package/dist/m365/spp/commands/model/model-list.js +57 -0
- package/dist/m365/spp/commands.js +2 -1
- package/dist/m365/teams/commands/channel/channel-get.js +15 -50
- package/dist/m365/teams/commands/team/team-get.js +16 -21
- package/dist/telemetryRunner.js +2 -2
- package/dist/utils/spo.js +90 -21
- package/dist/utils/spp.js +22 -0
- package/dist/utils/teams.js +47 -5
- package/dist/utils/timersUtil.js +2 -1
- package/dist/utils/zod.js +11 -2
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-add.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-get.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-list.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-member-add.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-member-get.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-member-list.mdx +0 -6
- package/docs/docs/cmd/entra/administrativeunit/administrativeunit-remove.mdx +0 -6
- package/docs/docs/cmd/entra/app/app-add.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-get.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-list.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-permission-add.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-permission-list.mdx +0 -6
- package/docs/docs/cmd/entra/app/app-remove.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-role-add.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-role-list.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-role-remove.mdx +0 -1
- package/docs/docs/cmd/entra/app/app-set.mdx +0 -1
- package/docs/docs/cmd/entra/approleassignment/approleassignment-add.mdx +0 -6
- package/docs/docs/cmd/entra/approleassignment/approleassignment-list.mdx +0 -6
- package/docs/docs/cmd/entra/approleassignment/approleassignment-remove.mdx +0 -6
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +0 -1
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +0 -1
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +0 -1
- package/docs/docs/cmd/entra/group/group-add.mdx +0 -6
- package/docs/docs/cmd/entra/group/group-get.mdx +0 -6
- package/docs/docs/cmd/entra/group/group-list.mdx +0 -6
- package/docs/docs/cmd/entra/group/group-member-list.mdx +0 -6
- package/docs/docs/cmd/entra/group/group-remove.mdx +0 -6
- package/docs/docs/cmd/entra/groupsetting/groupsetting-add.mdx +0 -6
- package/docs/docs/cmd/entra/groupsetting/groupsetting-get.mdx +0 -6
- package/docs/docs/cmd/entra/groupsetting/groupsetting-list.mdx +0 -6
- package/docs/docs/cmd/entra/groupsetting/groupsetting-remove.mdx +0 -6
- package/docs/docs/cmd/entra/groupsetting/groupsetting-set.mdx +0 -6
- package/docs/docs/cmd/entra/groupsettingtemplate/groupsettingtemplate-get.mdx +0 -6
- package/docs/docs/cmd/entra/groupsettingtemplate/groupsettingtemplate-list.mdx +0 -6
- package/docs/docs/cmd/entra/license/license-list.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-add.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-get.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-list.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-clear.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-remove.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-restore.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-remove.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-renew.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-report-activitycounts.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-report-activitydetail.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-report-activityfilecounts.mdx +0 -6
- package/docs/docs/cmd/entra/m365group/m365group-report-activitygroupcounts.mdx +2 -8
- package/docs/docs/cmd/entra/m365group/m365group-report-activitystorage.mdx +2 -8
- package/docs/docs/cmd/entra/m365group/m365group-set.mdx +34 -22
- package/docs/docs/cmd/entra/m365group/m365group-teamify.mdx +5 -11
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +5 -11
- package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +0 -12
- package/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx +26 -21
- package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +4 -17
- package/docs/docs/cmd/entra/oauth2grant/oauth2grant-add.mdx +3 -9
- package/docs/docs/cmd/entra/oauth2grant/oauth2grant-list.mdx +1 -7
- package/docs/docs/cmd/entra/oauth2grant/oauth2grant-remove.mdx +4 -10
- package/docs/docs/cmd/entra/oauth2grant/oauth2grant-set.mdx +3 -9
- package/docs/docs/cmd/entra/policy/policy-list.mdx +3 -9
- package/docs/docs/cmd/entra/siteclassification/siteclassification-disable.mdx +3 -9
- package/docs/docs/cmd/entra/siteclassification/siteclassification-enable.mdx +7 -13
- package/docs/docs/cmd/entra/siteclassification/siteclassification-get.mdx +1 -7
- package/docs/docs/cmd/entra/siteclassification/siteclassification-set.mdx +8 -14
- package/docs/docs/cmd/entra/user/user-add.mdx +4 -10
- package/docs/docs/cmd/entra/user/user-get.mdx +7 -13
- package/docs/docs/cmd/entra/user/user-guest-add.mdx +3 -9
- package/docs/docs/cmd/entra/user/user-hibp.mdx +2 -8
- package/docs/docs/cmd/entra/user/user-license-add.mdx +0 -6
- package/docs/docs/cmd/entra/user/user-license-list.mdx +0 -6
- package/docs/docs/cmd/entra/user/user-license-remove.mdx +2 -8
- package/docs/docs/cmd/entra/user/user-list.mdx +1 -7
- package/docs/docs/cmd/entra/user/user-password-validate.mdx +1 -7
- package/docs/docs/cmd/entra/user/user-recyclebinitem-clear.mdx +2 -8
- package/docs/docs/cmd/entra/user/user-recyclebinitem-list.mdx +0 -6
- package/docs/docs/cmd/entra/user/user-recyclebinitem-remove.mdx +2 -8
- package/docs/docs/cmd/entra/user/user-recyclebinitem-restore.mdx +0 -6
- package/docs/docs/cmd/entra/user/user-registrationdetails-list.mdx +7 -13
- package/docs/docs/cmd/entra/user/user-remove.mdx +2 -8
- package/docs/docs/cmd/entra/user/user-set.mdx +0 -6
- package/docs/docs/cmd/entra/user/user-signin-list.mdx +9 -15
- package/docs/docs/cmd/spo/file/file-move.mdx +1 -3
- package/docs/docs/cmd/spo/file/file-remove.mdx +13 -4
- package/docs/docs/cmd/spo/folder/folder-copy.mdx +84 -13
- package/docs/docs/cmd/spo/folder/folder-move.mdx +84 -13
- package/docs/docs/cmd/spo/group/group-member-add.mdx +8 -14
- package/docs/docs/cmd/spo/group/group-member-remove.mdx +5 -11
- package/docs/docs/cmd/spo/list/list-remove.mdx +10 -1
- package/docs/docs/cmd/spo/site/site-sharingpermission-set.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-site-membership-list.mdx +122 -0
- package/docs/docs/cmd/spo/user/user-ensure.mdx +2 -5
- package/docs/docs/cmd/spp/model/model-list.mdx +140 -0
- package/npm-shrinkwrap.json +2059 -389
- package/package.json +15 -15
- package/dist/m365/entra/aadCommands.js +0 -89
- package/dist/utils/driveUtil.js +0 -51
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import PeriodBasedReport from '../../../base/PeriodBasedReport.js';
|
|
2
|
-
import aadCommands from '../../aadCommands.js';
|
|
3
2
|
import commands from '../../commands.js';
|
|
4
3
|
class M365GroupReportActivityGroupCountsCommand extends PeriodBasedReport {
|
|
5
4
|
get name() {
|
|
@@ -8,9 +7,6 @@ class M365GroupReportActivityGroupCountsCommand extends PeriodBasedReport {
|
|
|
8
7
|
get description() {
|
|
9
8
|
return 'Get the daily total number of groups and how many of them were active based on email conversations, Viva Engage posts, and SharePoint file activities';
|
|
10
9
|
}
|
|
11
|
-
alias() {
|
|
12
|
-
return [aadCommands.M365GROUP_REPORT_ACTIVITYGROUPCOUNTS];
|
|
13
|
-
}
|
|
14
10
|
get usageEndpoint() {
|
|
15
11
|
return 'getOffice365GroupsActivityGroupCounts';
|
|
16
12
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import PeriodBasedReport from '../../../base/PeriodBasedReport.js';
|
|
2
|
-
import aadCommands from '../../aadCommands.js';
|
|
3
2
|
import commands from '../../commands.js';
|
|
4
3
|
class M365GroupReportActivityStorageCommand extends PeriodBasedReport {
|
|
5
4
|
get name() {
|
|
@@ -8,9 +7,6 @@ class M365GroupReportActivityStorageCommand extends PeriodBasedReport {
|
|
|
8
7
|
get description() {
|
|
9
8
|
return 'Get the total storage used across all group mailboxes and group sites';
|
|
10
9
|
}
|
|
11
|
-
alias() {
|
|
12
|
-
return [aadCommands.M365GROUP_REPORT_ACTIVITYSTORAGE];
|
|
13
|
-
}
|
|
14
10
|
get usageEndpoint() {
|
|
15
11
|
return 'getOffice365GroupsActivityStorage';
|
|
16
12
|
}
|
|
@@ -12,9 +12,11 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
13
|
import commands from '../../commands.js';
|
|
14
14
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
15
|
-
import aadCommands from '../../aadCommands.js';
|
|
16
15
|
import { accessToken } from '../../../../utils/accessToken.js';
|
|
17
16
|
import auth from '../../../../Auth.js';
|
|
17
|
+
import { entraUser } from '../../../../utils/entraUser.js';
|
|
18
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
19
|
+
import { odata } from '../../../../utils/odata.js';
|
|
18
20
|
class EntraM365GroupSetCommand extends GraphCommand {
|
|
19
21
|
get name() {
|
|
20
22
|
return commands.M365GROUP_SET;
|
|
@@ -22,9 +24,6 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
22
24
|
get description() {
|
|
23
25
|
return 'Updates Microsoft 365 Group properties';
|
|
24
26
|
}
|
|
25
|
-
alias() {
|
|
26
|
-
return [aadCommands.M365GROUP_SET];
|
|
27
|
-
}
|
|
28
27
|
constructor() {
|
|
29
28
|
super();
|
|
30
29
|
_EntraM365GroupSetCommand_instances.add(this);
|
|
@@ -36,7 +35,6 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
36
35
|
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initTypes).call(this);
|
|
37
36
|
}
|
|
38
37
|
async commandAction(logger, args) {
|
|
39
|
-
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_SET, commands.M365GROUP_SET);
|
|
40
38
|
try {
|
|
41
39
|
if ((args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined) && accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken)) {
|
|
42
40
|
throw `Option 'allowExternalSenders' and 'autoSubscribeNewMembers' can only be used when using delegated permissions.`;
|
|
@@ -102,59 +100,13 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
102
100
|
else if (this.debug) {
|
|
103
101
|
await logger.logToStderr('logoPath not set. Skipping');
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
const requestOptions = {
|
|
111
|
-
url: `${this.resource}/v1.0/users?$filter=${owners.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
|
|
112
|
-
headers: {
|
|
113
|
-
'content-type': 'application/json'
|
|
114
|
-
},
|
|
115
|
-
responseType: 'json'
|
|
116
|
-
};
|
|
117
|
-
const res = await request.get(requestOptions);
|
|
118
|
-
await Promise.all(res.value.map(u => request.post({
|
|
119
|
-
url: `${this.resource}/v1.0/groups/${groupId}/owners/$ref`,
|
|
120
|
-
headers: {
|
|
121
|
-
'content-type': 'application/json'
|
|
122
|
-
},
|
|
123
|
-
responseType: 'json',
|
|
124
|
-
data: {
|
|
125
|
-
"@odata.id": `https://graph.microsoft.com/v1.0/users/${u.id}`
|
|
126
|
-
}
|
|
127
|
-
})));
|
|
128
|
-
}
|
|
129
|
-
else if (this.debug) {
|
|
130
|
-
await logger.logToStderr('Owners not set. Skipping');
|
|
131
|
-
}
|
|
132
|
-
if (args.options.members) {
|
|
133
|
-
const members = args.options.members.split(',').map(o => o.trim());
|
|
134
|
-
if (this.verbose) {
|
|
135
|
-
await logger.logToStderr('Retrieving user information to set group members...');
|
|
136
|
-
}
|
|
137
|
-
const requestOptions = {
|
|
138
|
-
url: `${this.resource}/v1.0/users?$filter=${members.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
|
|
139
|
-
headers: {
|
|
140
|
-
'content-type': 'application/json'
|
|
141
|
-
},
|
|
142
|
-
responseType: 'json'
|
|
143
|
-
};
|
|
144
|
-
const res = await request.get(requestOptions);
|
|
145
|
-
await Promise.all(res.value.map(u => request.post({
|
|
146
|
-
url: `${this.resource}/v1.0/groups/${groupId}/members/$ref`,
|
|
147
|
-
headers: {
|
|
148
|
-
'content-type': 'application/json'
|
|
149
|
-
},
|
|
150
|
-
responseType: 'json',
|
|
151
|
-
data: {
|
|
152
|
-
"@odata.id": `https://graph.microsoft.com/v1.0/users/${u.id}`
|
|
153
|
-
}
|
|
154
|
-
})));
|
|
103
|
+
const ownerIds = await this.getUserIds(logger, args.options.ownerIds, args.options.ownerUserNames);
|
|
104
|
+
const memberIds = await this.getUserIds(logger, args.options.memberIds, args.options.memberUserNames);
|
|
105
|
+
if (ownerIds.length > 0) {
|
|
106
|
+
await this.updateUsers(logger, groupId, 'owners', ownerIds);
|
|
155
107
|
}
|
|
156
|
-
|
|
157
|
-
await
|
|
108
|
+
if (memberIds.length > 0) {
|
|
109
|
+
await this.updateUsers(logger, groupId, 'members', memberIds);
|
|
158
110
|
}
|
|
159
111
|
}
|
|
160
112
|
catch (err) {
|
|
@@ -186,6 +138,87 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
186
138
|
return 'image/jpeg';
|
|
187
139
|
}
|
|
188
140
|
}
|
|
141
|
+
async getUserIds(logger, userIds, userNames) {
|
|
142
|
+
if (userIds) {
|
|
143
|
+
return formatting.splitAndTrim(userIds);
|
|
144
|
+
}
|
|
145
|
+
if (userNames) {
|
|
146
|
+
if (this.verbose) {
|
|
147
|
+
await logger.logToStderr(`Retrieving user IDs...`);
|
|
148
|
+
}
|
|
149
|
+
return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
|
|
150
|
+
}
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
async updateUsers(logger, groupId, role, userIds) {
|
|
154
|
+
const groupUsers = await odata.getAllItems(`${this.resource}/v1.0/groups/${groupId}/${role}/microsoft.graph.user?$select=id`);
|
|
155
|
+
const userIdsToAdd = userIds.filter(userId => !groupUsers.some(groupUser => groupUser.id === userId));
|
|
156
|
+
const userIdsToRemove = groupUsers.filter(groupUser => !userIds.some(userId => groupUser.id === userId)).map(user => user.id);
|
|
157
|
+
if (this.verbose) {
|
|
158
|
+
await logger.logToStderr(`Adding ${userIdsToAdd.length} ${role}...`);
|
|
159
|
+
}
|
|
160
|
+
for (let i = 0; i < userIdsToAdd.length; i += 400) {
|
|
161
|
+
const userIdsBatch = userIdsToAdd.slice(i, i + 400);
|
|
162
|
+
const batchRequestOptions = this.getBatchRequestOptions();
|
|
163
|
+
// only 20 requests per one batch are allowed
|
|
164
|
+
for (let j = 0; j < userIdsBatch.length; j += 20) {
|
|
165
|
+
// only 20 users can be added in one request
|
|
166
|
+
const userIdsChunk = userIdsBatch.slice(j, j + 20);
|
|
167
|
+
batchRequestOptions.data.requests.push({
|
|
168
|
+
id: j + 1,
|
|
169
|
+
method: 'PATCH',
|
|
170
|
+
url: `/groups/${groupId}`,
|
|
171
|
+
headers: {
|
|
172
|
+
'content-type': 'application/json;odata.metadata=none',
|
|
173
|
+
accept: 'application/json;odata.metadata=none'
|
|
174
|
+
},
|
|
175
|
+
body: {
|
|
176
|
+
[`${role}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const res = await request.post(batchRequestOptions);
|
|
181
|
+
for (const response of res.responses) {
|
|
182
|
+
if (response.status !== 204) {
|
|
183
|
+
throw response.body;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (this.verbose) {
|
|
188
|
+
await logger.logToStderr(`Removing ${userIdsToRemove.length} ${role}...`);
|
|
189
|
+
}
|
|
190
|
+
for (let i = 0; i < userIdsToRemove.length; i += 20) {
|
|
191
|
+
const userIdsBatch = userIdsToRemove.slice(i, i + 20);
|
|
192
|
+
const batchRequestOptions = this.getBatchRequestOptions();
|
|
193
|
+
userIdsBatch.map(userId => {
|
|
194
|
+
batchRequestOptions.data.requests.push({
|
|
195
|
+
id: userId,
|
|
196
|
+
method: 'DELETE',
|
|
197
|
+
url: `/groups/${groupId}/${role}/${userId}/$ref`
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
const res = await request.post(batchRequestOptions);
|
|
201
|
+
for (const response of res.responses) {
|
|
202
|
+
if (response.status !== 204) {
|
|
203
|
+
throw response.body;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
getBatchRequestOptions() {
|
|
209
|
+
const requestOptions = {
|
|
210
|
+
url: `${this.resource}/v1.0/$batch`,
|
|
211
|
+
headers: {
|
|
212
|
+
'content-type': 'application/json;odata.metadata=none',
|
|
213
|
+
accept: 'application/json;odata.metadata=none'
|
|
214
|
+
},
|
|
215
|
+
responseType: 'json',
|
|
216
|
+
data: {
|
|
217
|
+
requests: []
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
return requestOptions;
|
|
221
|
+
}
|
|
189
222
|
}
|
|
190
223
|
_EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_initTelemetry = function _EntraM365GroupSetCommand_initTelemetry() {
|
|
191
224
|
this.telemetry.push((args) => {
|
|
@@ -194,8 +227,10 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
194
227
|
displayName: typeof args.options.displayName !== 'undefined',
|
|
195
228
|
newDisplayName: typeof args.options.newDisplayName !== 'undefined',
|
|
196
229
|
description: typeof args.options.description !== 'undefined',
|
|
197
|
-
|
|
198
|
-
|
|
230
|
+
ownerIds: typeof args.options.ownerIds !== 'undefined',
|
|
231
|
+
ownerUserNames: typeof args.options.ownerUserNames !== 'undefined',
|
|
232
|
+
memberIds: typeof args.options.memberIds !== 'undefined',
|
|
233
|
+
memberUserNames: typeof args.options.memberUserNames !== 'undefined',
|
|
199
234
|
isPrivate: !!args.options.isPrivate,
|
|
200
235
|
logoPath: typeof args.options.logoPath !== 'undefined',
|
|
201
236
|
allowExternalSenders: !!args.options.allowExternalSenders,
|
|
@@ -214,9 +249,13 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
214
249
|
}, {
|
|
215
250
|
option: '-d, --description [description]'
|
|
216
251
|
}, {
|
|
217
|
-
option: '--
|
|
252
|
+
option: '--ownerIds [ownerIds]'
|
|
218
253
|
}, {
|
|
219
|
-
option: '--
|
|
254
|
+
option: '--ownerUserNames [ownerUserNames]'
|
|
255
|
+
}, {
|
|
256
|
+
option: '--memberIds [memberIds]'
|
|
257
|
+
}, {
|
|
258
|
+
option: '--memberUserNames [memberUserNames]'
|
|
220
259
|
}, {
|
|
221
260
|
option: '--isPrivate [isPrivate]',
|
|
222
261
|
autocomplete: ['true', 'false']
|
|
@@ -237,17 +276,31 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
237
276
|
});
|
|
238
277
|
}, _EntraM365GroupSetCommand_initOptionSets = function _EntraM365GroupSetCommand_initOptionSets() {
|
|
239
278
|
this.optionSets.push({ options: ['id', 'displayName'] });
|
|
279
|
+
this.optionSets.push({
|
|
280
|
+
options: ['ownerIds', 'ownerUserNames'],
|
|
281
|
+
runsWhen: (args) => {
|
|
282
|
+
return args.options.ownerIds !== undefined || args.options.ownerUserNames !== undefined;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
this.optionSets.push({
|
|
286
|
+
options: ['memberIds', 'memberUserNames'],
|
|
287
|
+
runsWhen: (args) => {
|
|
288
|
+
return args.options.memberIds !== undefined || args.options.memberUserNames !== undefined;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
240
291
|
}, _EntraM365GroupSetCommand_initTypes = function _EntraM365GroupSetCommand_initTypes() {
|
|
241
292
|
this.types.boolean.push('isPrivate', 'allowEternalSenders', 'autoSubscribeNewMembers', 'hideFromAddressLists', 'hideFromOutlookClients');
|
|
242
|
-
this.types.string.push('id', 'displayName', 'newDisplayName', 'description', '
|
|
293
|
+
this.types.string.push('id', 'displayName', 'newDisplayName', 'description', 'ownerIds', 'ownerUserNames', 'memberIds', 'memberUserNames', 'logoPath');
|
|
243
294
|
}, _EntraM365GroupSetCommand_initValidators = function _EntraM365GroupSetCommand_initValidators() {
|
|
244
295
|
this.validators.push(async (args) => {
|
|
245
296
|
if (!args.options.newDisplayName &&
|
|
246
297
|
args.options.description === undefined &&
|
|
247
|
-
|
|
248
|
-
|
|
298
|
+
args.options.ownerIds === undefined &&
|
|
299
|
+
args.options.ownerUserNames === undefined &&
|
|
300
|
+
args.options.memberIds === undefined &&
|
|
301
|
+
args.options.memberUserNames === undefined &&
|
|
249
302
|
args.options.isPrivate === undefined &&
|
|
250
|
-
|
|
303
|
+
args.options.logoPath === undefined &&
|
|
251
304
|
args.options.allowExternalSenders === undefined &&
|
|
252
305
|
args.options.autoSubscribeNewMembers === undefined &&
|
|
253
306
|
args.options.hideFromAddressLists === undefined &&
|
|
@@ -257,16 +310,28 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
257
310
|
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
258
311
|
return `${args.options.id} is not a valid GUID`;
|
|
259
312
|
}
|
|
260
|
-
if (args.options.
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
return `
|
|
313
|
+
if (args.options.ownerIds) {
|
|
314
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ownerIds);
|
|
315
|
+
if (isValidGUIDArrayResult !== true) {
|
|
316
|
+
return `The following GUIDs are invalid for the option 'ownerIds': ${isValidGUIDArrayResult}.`;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (args.options.ownerUserNames) {
|
|
320
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.ownerUserNames);
|
|
321
|
+
if (isValidUPNArrayResult !== true) {
|
|
322
|
+
return `The following user principal names are invalid for the option 'ownerUserNames': ${isValidUPNArrayResult}.`;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (args.options.memberIds) {
|
|
326
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.memberIds);
|
|
327
|
+
if (isValidGUIDArrayResult !== true) {
|
|
328
|
+
return `The following GUIDs are invalid for the option 'memberIds': ${isValidGUIDArrayResult}.`;
|
|
264
329
|
}
|
|
265
330
|
}
|
|
266
|
-
if (args.options.
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
return `
|
|
331
|
+
if (args.options.memberUserNames) {
|
|
332
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.memberUserNames);
|
|
333
|
+
if (isValidUPNArrayResult !== true) {
|
|
334
|
+
return `The following user principal names are invalid for the option 'memberUserNames': ${isValidUPNArrayResult}.`;
|
|
270
335
|
}
|
|
271
336
|
}
|
|
272
337
|
if (args.options.logoPath) {
|
|
@@ -10,7 +10,6 @@ import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
|
10
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
11
|
import { validation } from '../../../../utils/validation.js';
|
|
12
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
|
-
import aadCommands from '../../aadCommands.js';
|
|
14
13
|
import commands from '../../commands.js';
|
|
15
14
|
class EntraM365GroupTeamifyCommand extends GraphCommand {
|
|
16
15
|
get name() {
|
|
@@ -19,9 +18,6 @@ class EntraM365GroupTeamifyCommand extends GraphCommand {
|
|
|
19
18
|
get description() {
|
|
20
19
|
return 'Creates a new Microsoft Teams team under existing Microsoft 365 group';
|
|
21
20
|
}
|
|
22
|
-
alias() {
|
|
23
|
-
return [aadCommands.M365GROUP_TEAMIFY];
|
|
24
|
-
}
|
|
25
21
|
constructor() {
|
|
26
22
|
super();
|
|
27
23
|
_EntraM365GroupTeamifyCommand_instances.add(this);
|
|
@@ -54,7 +50,6 @@ class EntraM365GroupTeamifyCommand extends GraphCommand {
|
|
|
54
50
|
return groupItem.id;
|
|
55
51
|
}
|
|
56
52
|
async commandAction(logger, args) {
|
|
57
|
-
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_TEAMIFY, commands.M365GROUP_TEAMIFY);
|
|
58
53
|
try {
|
|
59
54
|
const groupId = await this.getGroupId(args.options);
|
|
60
55
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
@@ -9,8 +9,6 @@ import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
|
-
import teamsCommands from '../../../teams/commands.js';
|
|
13
|
-
import aadCommands from '../../aadCommands.js';
|
|
14
12
|
import { entraUser } from '../../../../utils/entraUser.js';
|
|
15
13
|
import commands from '../../commands.js';
|
|
16
14
|
class EntraM365GroupUserAddCommand extends GraphCommand {
|
|
@@ -20,9 +18,6 @@ class EntraM365GroupUserAddCommand extends GraphCommand {
|
|
|
20
18
|
get description() {
|
|
21
19
|
return 'Adds user to specified Microsoft 365 Group or Microsoft Teams team';
|
|
22
20
|
}
|
|
23
|
-
alias() {
|
|
24
|
-
return [teamsCommands.USER_ADD, aadCommands.M365GROUP_USER_ADD];
|
|
25
|
-
}
|
|
26
21
|
constructor() {
|
|
27
22
|
super();
|
|
28
23
|
_EntraM365GroupUserAddCommand_instances.add(this);
|
|
@@ -34,7 +29,6 @@ class EntraM365GroupUserAddCommand extends GraphCommand {
|
|
|
34
29
|
__classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initTypes).call(this);
|
|
35
30
|
}
|
|
36
31
|
async commandAction(logger, args) {
|
|
37
|
-
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_ADD, commands.M365GROUP_USER_ADD);
|
|
38
32
|
try {
|
|
39
33
|
const providedGroupId = await this.getGroupId(logger, args);
|
|
40
34
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(providedGroupId);
|
|
@@ -9,7 +9,6 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
9
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
10
|
import commands from '../../commands.js';
|
|
11
11
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
12
|
-
import aadCommands from '../../aadCommands.js';
|
|
13
12
|
class EntraM365GroupUserListCommand extends GraphCommand {
|
|
14
13
|
get name() {
|
|
15
14
|
return commands.M365GROUP_USER_LIST;
|
|
@@ -17,9 +16,6 @@ class EntraM365GroupUserListCommand extends GraphCommand {
|
|
|
17
16
|
get description() {
|
|
18
17
|
return "Lists users for the specified Microsoft 365 group";
|
|
19
18
|
}
|
|
20
|
-
alias() {
|
|
21
|
-
return [aadCommands.M365GROUP_USER_LIST];
|
|
22
|
-
}
|
|
23
19
|
constructor() {
|
|
24
20
|
super();
|
|
25
21
|
_EntraM365GroupUserListCommand_instances.add(this);
|
|
@@ -29,7 +25,6 @@ class EntraM365GroupUserListCommand extends GraphCommand {
|
|
|
29
25
|
__classPrivateFieldGet(this, _EntraM365GroupUserListCommand_instances, "m", _EntraM365GroupUserListCommand_initValidators).call(this);
|
|
30
26
|
}
|
|
31
27
|
async commandAction(logger, args) {
|
|
32
|
-
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_LIST, commands.M365GROUP_USER_LIST);
|
|
33
28
|
try {
|
|
34
29
|
const groupId = await this.getGroupId(args.options, logger);
|
|
35
30
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
@@ -3,15 +3,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _EntraM365GroupUserRemoveCommand_instances, _EntraM365GroupUserRemoveCommand_initTelemetry, _EntraM365GroupUserRemoveCommand_initOptions, _EntraM365GroupUserRemoveCommand_initValidators, _EntraM365GroupUserRemoveCommand_initOptionSets;
|
|
6
|
+
var _EntraM365GroupUserRemoveCommand_instances, _EntraM365GroupUserRemoveCommand_initTelemetry, _EntraM365GroupUserRemoveCommand_initOptions, _EntraM365GroupUserRemoveCommand_initValidators, _EntraM365GroupUserRemoveCommand_initOptionSets, _EntraM365GroupUserRemoveCommand_initTypes;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
9
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
10
|
+
import { entraUser } from '../../../../utils/entraUser.js';
|
|
10
11
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
12
|
import { validation } from '../../../../utils/validation.js';
|
|
12
13
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
|
-
import teamsCommands from '../../../teams/commands.js';
|
|
14
|
-
import aadCommands from '../../aadCommands.js';
|
|
15
14
|
import commands from '../../commands.js';
|
|
16
15
|
class EntraM365GroupUserRemoveCommand extends GraphCommand {
|
|
17
16
|
get name() {
|
|
@@ -20,9 +19,6 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand {
|
|
|
20
19
|
get description() {
|
|
21
20
|
return 'Removes the specified user from specified Microsoft 365 Group or Microsoft Teams team';
|
|
22
21
|
}
|
|
23
|
-
alias() {
|
|
24
|
-
return [teamsCommands.USER_REMOVE, aadCommands.M365GROUP_USER_REMOVE];
|
|
25
|
-
}
|
|
26
22
|
constructor() {
|
|
27
23
|
super();
|
|
28
24
|
_EntraM365GroupUserRemoveCommand_instances.add(this);
|
|
@@ -30,61 +26,20 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand {
|
|
|
30
26
|
__classPrivateFieldGet(this, _EntraM365GroupUserRemoveCommand_instances, "m", _EntraM365GroupUserRemoveCommand_initOptions).call(this);
|
|
31
27
|
__classPrivateFieldGet(this, _EntraM365GroupUserRemoveCommand_instances, "m", _EntraM365GroupUserRemoveCommand_initValidators).call(this);
|
|
32
28
|
__classPrivateFieldGet(this, _EntraM365GroupUserRemoveCommand_instances, "m", _EntraM365GroupUserRemoveCommand_initOptionSets).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _EntraM365GroupUserRemoveCommand_instances, "m", _EntraM365GroupUserRemoveCommand_initTypes).call(this);
|
|
33
30
|
}
|
|
34
31
|
async commandAction(logger, args) {
|
|
35
|
-
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_REMOVE, commands.M365GROUP_USER_REMOVE);
|
|
36
|
-
const groupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
|
|
37
32
|
const removeUser = async () => {
|
|
38
33
|
try {
|
|
34
|
+
const groupId = await this.getGroupId(logger, args.options.groupId, args.options.teamId, args.options.groupName, args.options.teamName);
|
|
39
35
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
40
36
|
if (!isUnifiedGroup) {
|
|
41
37
|
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
accept: 'application/json;odata.metadata=none'
|
|
48
|
-
},
|
|
49
|
-
responseType: 'json'
|
|
50
|
-
});
|
|
51
|
-
// used to verify if the group exists or not
|
|
52
|
-
await request.get({
|
|
53
|
-
url: `${this.resource}/v1.0/groups/${groupId}/id`,
|
|
54
|
-
headers: {
|
|
55
|
-
'accept': 'application/json;odata.metadata=none'
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
try {
|
|
59
|
-
// try to delete the user from the owners. Accepted error is 404
|
|
60
|
-
await request.delete({
|
|
61
|
-
url: `${this.resource}/v1.0/groups/${groupId}/owners/${user.value}/$ref`,
|
|
62
|
-
headers: {
|
|
63
|
-
'accept': 'application/json;odata.metadata=none'
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
// the 404 error is accepted
|
|
69
|
-
if (err.response.status !== 404) {
|
|
70
|
-
throw err.response.data;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
// try to delete the user from the members. Accepted error is 404
|
|
74
|
-
try {
|
|
75
|
-
await request.delete({
|
|
76
|
-
url: `${this.resource}/v1.0/groups/${groupId}/members/${user.value}/$ref`,
|
|
77
|
-
headers: {
|
|
78
|
-
'accept': 'application/json;odata.metadata=none'
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
// the 404 error is accepted
|
|
84
|
-
if (err.response.status !== 404) {
|
|
85
|
-
throw err.response.data;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
39
|
+
const userNames = args.options.userNames;
|
|
40
|
+
const userIds = await this.getUserIds(logger, args.options.ids, userNames);
|
|
41
|
+
await this.removeUsersFromGroup(groupId, userIds, 'owners');
|
|
42
|
+
await this.removeUsersFromGroup(groupId, userIds, 'members');
|
|
88
43
|
}
|
|
89
44
|
catch (err) {
|
|
90
45
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -94,43 +49,110 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand {
|
|
|
94
49
|
await removeUser();
|
|
95
50
|
}
|
|
96
51
|
else {
|
|
97
|
-
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove ${args.options.
|
|
52
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove ${args.options.userNames || args.options.ids} from ${args.options.groupId || args.options.groupName || args.options.teamId || args.options.teamName}?` });
|
|
98
53
|
if (result) {
|
|
99
54
|
await removeUser();
|
|
100
55
|
}
|
|
101
56
|
}
|
|
102
57
|
}
|
|
58
|
+
async getGroupId(logger, groupId, teamId, groupName, teamName) {
|
|
59
|
+
const id = groupId || teamId;
|
|
60
|
+
if (id) {
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
const name = groupName ?? teamName;
|
|
64
|
+
if (this.verbose) {
|
|
65
|
+
await logger.logToStderr(`Retrieving Group ID by display name ${name}...`);
|
|
66
|
+
}
|
|
67
|
+
return entraGroup.getGroupIdByDisplayName(name);
|
|
68
|
+
}
|
|
69
|
+
async getUserIds(logger, userIds, userNames) {
|
|
70
|
+
if (userIds) {
|
|
71
|
+
return formatting.splitAndTrim(userIds);
|
|
72
|
+
}
|
|
73
|
+
if (this.verbose) {
|
|
74
|
+
await logger.logToStderr(`Retrieving user IDs for {userNames}...`);
|
|
75
|
+
}
|
|
76
|
+
return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
|
|
77
|
+
}
|
|
78
|
+
async removeUsersFromGroup(groupId, userIds, role) {
|
|
79
|
+
for (const userId of userIds) {
|
|
80
|
+
try {
|
|
81
|
+
await request.delete({
|
|
82
|
+
url: `${this.resource}/v1.0/groups/${groupId}/${role}/${userId}/$ref`,
|
|
83
|
+
headers: {
|
|
84
|
+
'accept': 'application/json;odata.metadata=none'
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
// the 404 error is accepted
|
|
90
|
+
if (err.response.status !== 404) {
|
|
91
|
+
throw err.response.data;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
103
96
|
}
|
|
104
97
|
_EntraM365GroupUserRemoveCommand_instances = new WeakSet(), _EntraM365GroupUserRemoveCommand_initTelemetry = function _EntraM365GroupUserRemoveCommand_initTelemetry() {
|
|
105
98
|
this.telemetry.push((args) => {
|
|
106
99
|
Object.assign(this.telemetryProperties, {
|
|
107
|
-
force:
|
|
100
|
+
force: !!args.options.force,
|
|
108
101
|
teamId: typeof args.options.teamId !== 'undefined',
|
|
109
|
-
groupId: typeof args.options.groupId !== 'undefined'
|
|
102
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
103
|
+
teamName: typeof args.options.teamName !== 'undefined',
|
|
104
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
105
|
+
ids: typeof args.options.ids !== 'undefined',
|
|
106
|
+
userNames: typeof args.options.userNames !== 'undefined'
|
|
110
107
|
});
|
|
111
108
|
});
|
|
112
109
|
}, _EntraM365GroupUserRemoveCommand_initOptions = function _EntraM365GroupUserRemoveCommand_initOptions() {
|
|
113
110
|
this.options.unshift({
|
|
114
|
-
option:
|
|
111
|
+
option: '-i, --groupId [groupId]'
|
|
115
112
|
}, {
|
|
116
|
-
option:
|
|
113
|
+
option: '--groupName [groupName]'
|
|
117
114
|
}, {
|
|
118
|
-
option: '
|
|
115
|
+
option: '--teamId [teamId]'
|
|
116
|
+
}, {
|
|
117
|
+
option: '--teamName [teamName]'
|
|
118
|
+
}, {
|
|
119
|
+
option: '--ids [ids]'
|
|
120
|
+
}, {
|
|
121
|
+
option: '--userNames [userNames]'
|
|
119
122
|
}, {
|
|
120
123
|
option: '-f, --force'
|
|
121
124
|
});
|
|
122
125
|
}, _EntraM365GroupUserRemoveCommand_initValidators = function _EntraM365GroupUserRemoveCommand_initValidators() {
|
|
123
126
|
this.validators.push(async (args) => {
|
|
124
127
|
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
125
|
-
return `${args.options.teamId} is not a valid GUID
|
|
128
|
+
return `${args.options.teamId} is not a valid GUID for option 'teamId'.`;
|
|
126
129
|
}
|
|
127
130
|
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
128
|
-
return `${args.options.groupId} is not a valid GUID
|
|
131
|
+
return `${args.options.groupId} is not a valid GUID for option 'groupId'.`;
|
|
132
|
+
}
|
|
133
|
+
if (args.options.ids) {
|
|
134
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
|
|
135
|
+
if (isValidGUIDArrayResult !== true) {
|
|
136
|
+
return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (args.options.userNames) {
|
|
140
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userNames);
|
|
141
|
+
if (isValidUPNArrayResult !== true) {
|
|
142
|
+
return `The following user principal names are invalid for the option 'userNames': ${isValidUPNArrayResult}.`;
|
|
143
|
+
}
|
|
129
144
|
}
|
|
130
145
|
return true;
|
|
131
146
|
});
|
|
132
147
|
}, _EntraM365GroupUserRemoveCommand_initOptionSets = function _EntraM365GroupUserRemoveCommand_initOptionSets() {
|
|
133
|
-
this.optionSets.push({
|
|
148
|
+
this.optionSets.push({
|
|
149
|
+
options: ['groupId', 'teamId', 'groupName', 'teamName']
|
|
150
|
+
}, {
|
|
151
|
+
options: ['ids', 'userNames']
|
|
152
|
+
});
|
|
153
|
+
}, _EntraM365GroupUserRemoveCommand_initTypes = function _EntraM365GroupUserRemoveCommand_initTypes() {
|
|
154
|
+
this.types.string.push('groupId', 'groupName', 'teamId', 'teamName', 'ids', 'userNames');
|
|
155
|
+
this.types.boolean.push('force');
|
|
134
156
|
};
|
|
135
157
|
export default new EntraM365GroupUserRemoveCommand();
|
|
136
158
|
//# sourceMappingURL=m365group-user-remove.js.map
|