@pnp/cli-microsoft365 10.0.0-beta.d126736 → 10.0.0-beta.da65889
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/m365/commands/login.js +120 -67
- package/dist/m365/entra/commands/group/{group-user-add.js → group-member-add.js} +18 -18
- package/dist/m365/entra/commands/group/{group-user-list.js → group-member-list.js} +17 -17
- package/dist/m365/entra/commands/group/{group-user-set.js → group-member-set.js} +19 -19
- package/dist/m365/entra/commands.js +3 -3
- package/docs/docs/cmd/entra/group/group-member-add.mdx +62 -0
- package/docs/docs/cmd/entra/group/{group-user-list.mdx → group-member-list.mdx} +14 -14
- package/docs/docs/cmd/entra/group/group-member-set.mdx +62 -0
- package/docs/docs/cmd/login.mdx +9 -0
- package/package.json +1 -1
- package/docs/docs/cmd/entra/group/group-user-add.mdx +0 -62
- package/docs/docs/cmd/entra/group/group-user-set.mdx +0 -62
|
@@ -21,7 +21,8 @@ const options = globalOptionsZod
|
|
|
21
21
|
appId: z.string().optional(),
|
|
22
22
|
tenant: z.string().optional(),
|
|
23
23
|
secret: zod.alias('s', z.string().optional()),
|
|
24
|
-
connectionName: z.string().optional()
|
|
24
|
+
connectionName: z.string().optional(),
|
|
25
|
+
ensure: z.boolean().optional()
|
|
25
26
|
})
|
|
26
27
|
.strict();
|
|
27
28
|
class LoginCommand extends Command {
|
|
@@ -67,75 +68,16 @@ class LoginCommand extends Command {
|
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
async commandAction(logger, args) {
|
|
70
|
-
// disconnect before re-connecting
|
|
71
71
|
if (this.debug) {
|
|
72
72
|
await logger.logToStderr(`Logging out from Microsoft 365...`);
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return options.certificateBase64Encoded;
|
|
82
|
-
}
|
|
83
|
-
return cli.getConfig().get(settingsNames.clientCertificateFile) ||
|
|
84
|
-
cli.getConfig().get(settingsNames.clientCertificateBase64Encoded);
|
|
85
|
-
};
|
|
86
|
-
const login = async () => {
|
|
87
|
-
if (this.verbose) {
|
|
88
|
-
await logger.logToStderr(`Signing in to Microsoft 365...`);
|
|
89
|
-
}
|
|
90
|
-
const authType = args.options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode');
|
|
91
|
-
auth.connection.appId = args.options.appId || cli.getClientId();
|
|
92
|
-
auth.connection.tenant = args.options.tenant || cli.getTenant();
|
|
93
|
-
auth.connection.name = args.options.connectionName;
|
|
94
|
-
switch (authType) {
|
|
95
|
-
case 'password':
|
|
96
|
-
auth.connection.authType = AuthType.Password;
|
|
97
|
-
auth.connection.userName = args.options.userName;
|
|
98
|
-
auth.connection.password = args.options.password;
|
|
99
|
-
break;
|
|
100
|
-
case 'certificate':
|
|
101
|
-
auth.connection.authType = AuthType.Certificate;
|
|
102
|
-
auth.connection.certificate = getCertificate(args.options);
|
|
103
|
-
auth.connection.thumbprint = args.options.thumbprint;
|
|
104
|
-
auth.connection.password = args.options.password ?? cli.getConfig().get(settingsNames.clientCertificatePassword);
|
|
105
|
-
break;
|
|
106
|
-
case 'identity':
|
|
107
|
-
auth.connection.authType = AuthType.Identity;
|
|
108
|
-
auth.connection.userName = args.options.userName;
|
|
109
|
-
break;
|
|
110
|
-
case 'browser':
|
|
111
|
-
auth.connection.authType = AuthType.Browser;
|
|
112
|
-
break;
|
|
113
|
-
case 'secret':
|
|
114
|
-
auth.connection.authType = AuthType.Secret;
|
|
115
|
-
auth.connection.secret = args.options.secret || cli.getConfig().get(settingsNames.clientSecret);
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
auth.connection.cloudType = args.options.cloud;
|
|
119
|
-
try {
|
|
120
|
-
await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
|
|
121
|
-
auth.connection.active = true;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
if (this.debug) {
|
|
125
|
-
await logger.logToStderr('Error:');
|
|
126
|
-
await logger.logToStderr(error);
|
|
127
|
-
await logger.logToStderr('');
|
|
128
|
-
}
|
|
129
|
-
throw new CommandError(error.message);
|
|
130
|
-
}
|
|
131
|
-
const details = auth.getConnectionDetails(auth.connection);
|
|
132
|
-
if (this.debug) {
|
|
133
|
-
details.accessToken = JSON.stringify(auth.connection.accessTokens, null, 2);
|
|
134
|
-
}
|
|
135
|
-
await logger.log(details);
|
|
136
|
-
};
|
|
137
|
-
deactivate();
|
|
138
|
-
await login();
|
|
74
|
+
if (this.shouldLogin(args.options)) {
|
|
75
|
+
auth.connection.deactivate();
|
|
76
|
+
await this.login(logger, args);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
await this.ensureAccessToken(logger);
|
|
80
|
+
}
|
|
139
81
|
}
|
|
140
82
|
async action(logger, args) {
|
|
141
83
|
try {
|
|
@@ -147,6 +89,117 @@ class LoginCommand extends Command {
|
|
|
147
89
|
await this.initAction(args, logger);
|
|
148
90
|
await this.commandAction(logger, args);
|
|
149
91
|
}
|
|
92
|
+
shouldLogin(options) {
|
|
93
|
+
if (!auth.connection.active) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (!options.ensure) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
const authType = options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode');
|
|
100
|
+
if (authType !== auth.connection.authType) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (options.cloud !== auth.connection.cloudType) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (options.appId && options.appId !== auth.connection.appId) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (options.tenant && options.tenant !== auth.connection.tenant) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
if (authType === AuthType.Password && (options.password && options.userName !== auth.connection.userName)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (authType === AuthType.Certificate && (options.certificateFile && (auth.connection.certificate !== fs.readFileSync(options.certificateFile, 'base64')))) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (authType === AuthType.Identity && (options.userName && options.userName !== auth.connection.userName)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (authType === AuthType.Secret && (options.secret && options.secret !== auth.connection.secret)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
const now = new Date();
|
|
125
|
+
const accessToken = auth.connection.accessTokens[auth.defaultResource];
|
|
126
|
+
const expiresOn = accessToken && accessToken.expiresOn ?
|
|
127
|
+
// if expiresOn is serialized from the service file, it's set as a string
|
|
128
|
+
// if it's coming from MSAL, it's a Date
|
|
129
|
+
typeof accessToken.expiresOn === 'string' ? new Date(accessToken.expiresOn) : accessToken.expiresOn
|
|
130
|
+
: new Date(0);
|
|
131
|
+
if (expiresOn < now) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
async ensureAccessToken(logger) {
|
|
137
|
+
try {
|
|
138
|
+
await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
|
|
139
|
+
auth.connection.active = true;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (this.debug) {
|
|
143
|
+
await logger.logToStderr('Error:');
|
|
144
|
+
await logger.logToStderr(error);
|
|
145
|
+
await logger.logToStderr('');
|
|
146
|
+
}
|
|
147
|
+
throw new CommandError(error.message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
getCertificate(options) {
|
|
151
|
+
// command args take precedence over settings
|
|
152
|
+
if (options.certificateFile) {
|
|
153
|
+
return fs.readFileSync(options.certificateFile).toString('base64');
|
|
154
|
+
}
|
|
155
|
+
if (options.certificateBase64Encoded) {
|
|
156
|
+
return options.certificateBase64Encoded;
|
|
157
|
+
}
|
|
158
|
+
return cli.getConfig().get(settingsNames.clientCertificateFile) ||
|
|
159
|
+
cli.getConfig().get(settingsNames.clientCertificateBase64Encoded);
|
|
160
|
+
}
|
|
161
|
+
;
|
|
162
|
+
async login(logger, args) {
|
|
163
|
+
if (this.verbose) {
|
|
164
|
+
await logger.logToStderr(`Signing in to Microsoft 365...`);
|
|
165
|
+
}
|
|
166
|
+
const authType = args.options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode');
|
|
167
|
+
auth.connection.appId = args.options.appId || cli.getClientId();
|
|
168
|
+
auth.connection.tenant = args.options.tenant || cli.getTenant();
|
|
169
|
+
auth.connection.name = args.options.connectionName;
|
|
170
|
+
switch (authType) {
|
|
171
|
+
case 'password':
|
|
172
|
+
auth.connection.authType = AuthType.Password;
|
|
173
|
+
auth.connection.userName = args.options.userName;
|
|
174
|
+
auth.connection.password = args.options.password;
|
|
175
|
+
break;
|
|
176
|
+
case 'certificate':
|
|
177
|
+
auth.connection.authType = AuthType.Certificate;
|
|
178
|
+
auth.connection.certificate = this.getCertificate(args.options);
|
|
179
|
+
auth.connection.thumbprint = args.options.thumbprint;
|
|
180
|
+
auth.connection.password = args.options.password ?? cli.getConfig().get(settingsNames.clientCertificatePassword);
|
|
181
|
+
break;
|
|
182
|
+
case 'identity':
|
|
183
|
+
auth.connection.authType = AuthType.Identity;
|
|
184
|
+
auth.connection.userName = args.options.userName;
|
|
185
|
+
break;
|
|
186
|
+
case 'browser':
|
|
187
|
+
auth.connection.authType = AuthType.Browser;
|
|
188
|
+
break;
|
|
189
|
+
case 'secret':
|
|
190
|
+
auth.connection.authType = AuthType.Secret;
|
|
191
|
+
auth.connection.secret = args.options.secret || cli.getConfig().get(settingsNames.clientSecret);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
auth.connection.cloudType = args.options.cloud;
|
|
195
|
+
await this.ensureAccessToken(logger);
|
|
196
|
+
const details = auth.getConnectionDetails(auth.connection);
|
|
197
|
+
if (this.debug) {
|
|
198
|
+
details.accessToken = JSON.stringify(auth.connection.accessTokens, null, 2);
|
|
199
|
+
}
|
|
200
|
+
await logger.log(details);
|
|
201
|
+
}
|
|
202
|
+
;
|
|
150
203
|
}
|
|
151
204
|
export default new LoginCommand();
|
|
152
205
|
//# sourceMappingURL=login.js.map
|
|
@@ -3,34 +3,34 @@ 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
|
|
6
|
+
var _EntraGroupMemberAddCommand_instances, _EntraGroupMemberAddCommand_initTelemetry, _EntraGroupMemberAddCommand_initOptions, _EntraGroupMemberAddCommand_initValidators, _EntraGroupMemberAddCommand_initOptionSets, _EntraGroupMemberAddCommand_initTypes;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
8
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
9
|
import { entraUser } from '../../../../utils/entraUser.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
-
class
|
|
13
|
+
class EntraGroupMemberAddCommand extends GraphCommand {
|
|
14
14
|
get name() {
|
|
15
|
-
return commands.
|
|
15
|
+
return commands.GROUP_MEMBER_ADD;
|
|
16
16
|
}
|
|
17
17
|
get description() {
|
|
18
|
-
return 'Adds a
|
|
18
|
+
return 'Adds a member to a Microsoft Entra ID group';
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
22
|
-
|
|
22
|
+
_EntraGroupMemberAddCommand_instances.add(this);
|
|
23
23
|
this.roleValues = ['Owner', 'Member'];
|
|
24
|
-
__classPrivateFieldGet(this,
|
|
25
|
-
__classPrivateFieldGet(this,
|
|
26
|
-
__classPrivateFieldGet(this,
|
|
27
|
-
__classPrivateFieldGet(this,
|
|
28
|
-
__classPrivateFieldGet(this,
|
|
24
|
+
__classPrivateFieldGet(this, _EntraGroupMemberAddCommand_instances, "m", _EntraGroupMemberAddCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _EntraGroupMemberAddCommand_instances, "m", _EntraGroupMemberAddCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _EntraGroupMemberAddCommand_instances, "m", _EntraGroupMemberAddCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _EntraGroupMemberAddCommand_instances, "m", _EntraGroupMemberAddCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _EntraGroupMemberAddCommand_instances, "m", _EntraGroupMemberAddCommand_initTypes).call(this);
|
|
29
29
|
}
|
|
30
30
|
async commandAction(logger, args) {
|
|
31
31
|
try {
|
|
32
32
|
if (this.verbose) {
|
|
33
|
-
await logger.logToStderr(`Adding
|
|
33
|
+
await logger.logToStderr(`Adding member(s) ${args.options.ids || args.options.userNames} to group ${args.options.groupId || args.options.groupDisplayName}...`);
|
|
34
34
|
}
|
|
35
35
|
const groupId = await this.getGroupId(logger, args.options);
|
|
36
36
|
const userIds = await this.getUserIds(logger, args.options);
|
|
@@ -91,7 +91,7 @@ class EntraGroupUserAddCommand extends GraphCommand {
|
|
|
91
91
|
return entraUser.getUserIdsByUpns(options.userNames.split(',').map(u => u.trim()));
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
_EntraGroupMemberAddCommand_instances = new WeakSet(), _EntraGroupMemberAddCommand_initTelemetry = function _EntraGroupMemberAddCommand_initTelemetry() {
|
|
95
95
|
this.telemetry.push((args) => {
|
|
96
96
|
Object.assign(this.telemetryProperties, {
|
|
97
97
|
groupId: typeof args.options.groupId !== 'undefined',
|
|
@@ -100,7 +100,7 @@ _EntraGroupUserAddCommand_instances = new WeakSet(), _EntraGroupUserAddCommand_i
|
|
|
100
100
|
userNames: typeof args.options.userNames !== 'undefined'
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
|
-
},
|
|
103
|
+
}, _EntraGroupMemberAddCommand_initOptions = function _EntraGroupMemberAddCommand_initOptions() {
|
|
104
104
|
this.options.unshift({
|
|
105
105
|
option: '-i, --groupId [groupId]'
|
|
106
106
|
}, {
|
|
@@ -113,7 +113,7 @@ _EntraGroupUserAddCommand_instances = new WeakSet(), _EntraGroupUserAddCommand_i
|
|
|
113
113
|
option: '-r, --role <role>',
|
|
114
114
|
autocomplete: this.roleValues
|
|
115
115
|
});
|
|
116
|
-
},
|
|
116
|
+
}, _EntraGroupMemberAddCommand_initValidators = function _EntraGroupMemberAddCommand_initValidators() {
|
|
117
117
|
this.validators.push(async (args) => {
|
|
118
118
|
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
119
119
|
return `${args.options.groupId} is not a valid GUID for option groupId.`;
|
|
@@ -135,10 +135,10 @@ _EntraGroupUserAddCommand_instances = new WeakSet(), _EntraGroupUserAddCommand_i
|
|
|
135
135
|
}
|
|
136
136
|
return true;
|
|
137
137
|
});
|
|
138
|
-
},
|
|
138
|
+
}, _EntraGroupMemberAddCommand_initOptionSets = function _EntraGroupMemberAddCommand_initOptionSets() {
|
|
139
139
|
this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }, { options: ['ids', 'userNames'] });
|
|
140
|
-
},
|
|
140
|
+
}, _EntraGroupMemberAddCommand_initTypes = function _EntraGroupMemberAddCommand_initTypes() {
|
|
141
141
|
this.types.string.push('groupId', 'groupDisplayName', 'ids', 'userNames', 'role');
|
|
142
142
|
};
|
|
143
|
-
export default new
|
|
144
|
-
//# sourceMappingURL=group-
|
|
143
|
+
export default new EntraGroupMemberAddCommand();
|
|
144
|
+
//# sourceMappingURL=group-member-add.js.map
|
|
@@ -3,19 +3,19 @@ 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
|
|
6
|
+
var _EntraGroupMemberListCommand_instances, _EntraGroupMemberListCommand_initTelemetry, _EntraGroupMemberListCommand_initOptions, _EntraGroupMemberListCommand_initOptionSets, _EntraGroupMemberListCommand_initValidators;
|
|
7
7
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
8
8
|
import { odata } from '../../../../utils/odata.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import commands from '../../commands.js';
|
|
12
12
|
import aadCommands from '../../aadCommands.js';
|
|
13
|
-
class
|
|
13
|
+
class EntraGroupMemberListCommand extends GraphCommand {
|
|
14
14
|
get name() {
|
|
15
|
-
return commands.
|
|
15
|
+
return commands.GROUP_MEMBER_LIST;
|
|
16
16
|
}
|
|
17
17
|
get description() {
|
|
18
|
-
return 'Lists
|
|
18
|
+
return 'Lists members of a specific Entra group';
|
|
19
19
|
}
|
|
20
20
|
alias() {
|
|
21
21
|
return [aadCommands.GROUP_USER_LIST];
|
|
@@ -25,14 +25,14 @@ class EntraGroupUserListCommand extends GraphCommand {
|
|
|
25
25
|
}
|
|
26
26
|
constructor() {
|
|
27
27
|
super();
|
|
28
|
-
|
|
29
|
-
__classPrivateFieldGet(this,
|
|
30
|
-
__classPrivateFieldGet(this,
|
|
31
|
-
__classPrivateFieldGet(this,
|
|
32
|
-
__classPrivateFieldGet(this,
|
|
28
|
+
_EntraGroupMemberListCommand_instances.add(this);
|
|
29
|
+
__classPrivateFieldGet(this, _EntraGroupMemberListCommand_instances, "m", _EntraGroupMemberListCommand_initTelemetry).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _EntraGroupMemberListCommand_instances, "m", _EntraGroupMemberListCommand_initOptions).call(this);
|
|
31
|
+
__classPrivateFieldGet(this, _EntraGroupMemberListCommand_instances, "m", _EntraGroupMemberListCommand_initOptionSets).call(this);
|
|
32
|
+
__classPrivateFieldGet(this, _EntraGroupMemberListCommand_instances, "m", _EntraGroupMemberListCommand_initValidators).call(this);
|
|
33
33
|
}
|
|
34
34
|
async commandAction(logger, args) {
|
|
35
|
-
await this.showDeprecationWarning(logger, aadCommands.GROUP_USER_LIST, commands.
|
|
35
|
+
await this.showDeprecationWarning(logger, aadCommands.GROUP_USER_LIST, commands.GROUP_MEMBER_LIST);
|
|
36
36
|
try {
|
|
37
37
|
const groupId = await this.getGroupId(args.options, logger);
|
|
38
38
|
const users = [];
|
|
@@ -86,7 +86,7 @@ class EntraGroupUserListCommand extends GraphCommand {
|
|
|
86
86
|
});
|
|
87
87
|
const expandParam = fieldExpand.length > 0 ? `&$expand=${fieldExpand}` : '';
|
|
88
88
|
const selectParam = allSelectProperties.filter(item => !item.includes('/'));
|
|
89
|
-
const endpoint = `${this.resource}/v1.0/groups/${groupId}/${role}
|
|
89
|
+
const endpoint = `${this.resource}/v1.0/groups/${groupId}/${role}?$select=${selectParam}${expandParam}`;
|
|
90
90
|
let users = [];
|
|
91
91
|
if (filter) {
|
|
92
92
|
// While using the filter, we need to specify the ConsistencyLevel header.
|
|
@@ -107,7 +107,7 @@ class EntraGroupUserListCommand extends GraphCommand {
|
|
|
107
107
|
return users;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
_EntraGroupMemberListCommand_instances = new WeakSet(), _EntraGroupMemberListCommand_initTelemetry = function _EntraGroupMemberListCommand_initTelemetry() {
|
|
111
111
|
this.telemetry.push((args) => {
|
|
112
112
|
Object.assign(this.telemetryProperties, {
|
|
113
113
|
groupId: typeof args.options.groupId !== 'undefined',
|
|
@@ -117,7 +117,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
117
117
|
filter: typeof args.options.filter !== 'undefined'
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
|
-
},
|
|
120
|
+
}, _EntraGroupMemberListCommand_initOptions = function _EntraGroupMemberListCommand_initOptions() {
|
|
121
121
|
this.options.unshift({
|
|
122
122
|
option: "-i, --groupId [groupId]"
|
|
123
123
|
}, {
|
|
@@ -130,11 +130,11 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
130
130
|
}, {
|
|
131
131
|
option: "-f, --filter [filter]"
|
|
132
132
|
});
|
|
133
|
-
},
|
|
133
|
+
}, _EntraGroupMemberListCommand_initOptionSets = function _EntraGroupMemberListCommand_initOptionSets() {
|
|
134
134
|
this.optionSets.push({
|
|
135
135
|
options: ['groupId', 'groupName']
|
|
136
136
|
});
|
|
137
|
-
},
|
|
137
|
+
}, _EntraGroupMemberListCommand_initValidators = function _EntraGroupMemberListCommand_initValidators() {
|
|
138
138
|
this.validators.push(async (args) => {
|
|
139
139
|
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
140
140
|
return `${args.options.groupId} is not a valid GUID`;
|
|
@@ -147,5 +147,5 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
|
|
|
147
147
|
return true;
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
|
-
export default new
|
|
151
|
-
//# sourceMappingURL=group-
|
|
150
|
+
export default new EntraGroupMemberListCommand();
|
|
151
|
+
//# sourceMappingURL=group-member-list.js.map
|
|
@@ -3,34 +3,34 @@ 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
|
|
6
|
+
var _EntraGroupMemberSetCommand_instances, _EntraGroupMemberSetCommand_initTelemetry, _EntraGroupMemberSetCommand_initOptions, _EntraGroupMemberSetCommand_initValidators, _EntraGroupMemberSetCommand_initOptionSets, _EntraGroupMemberSetCommand_initTypes;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
8
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
9
|
import { entraUser } from '../../../../utils/entraUser.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
-
class
|
|
13
|
+
class EntraGroupMemberSetCommand extends GraphCommand {
|
|
14
14
|
get name() {
|
|
15
|
-
return commands.
|
|
15
|
+
return commands.GROUP_MEMBER_SET;
|
|
16
16
|
}
|
|
17
17
|
get description() {
|
|
18
|
-
return 'Updates role of
|
|
18
|
+
return 'Updates the role of members in a Microsoft Entra ID group';
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
22
|
-
|
|
22
|
+
_EntraGroupMemberSetCommand_instances.add(this);
|
|
23
23
|
this.roleValues = ['Owner', 'Member'];
|
|
24
|
-
__classPrivateFieldGet(this,
|
|
25
|
-
__classPrivateFieldGet(this,
|
|
26
|
-
__classPrivateFieldGet(this,
|
|
27
|
-
__classPrivateFieldGet(this,
|
|
28
|
-
__classPrivateFieldGet(this,
|
|
24
|
+
__classPrivateFieldGet(this, _EntraGroupMemberSetCommand_instances, "m", _EntraGroupMemberSetCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _EntraGroupMemberSetCommand_instances, "m", _EntraGroupMemberSetCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _EntraGroupMemberSetCommand_instances, "m", _EntraGroupMemberSetCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _EntraGroupMemberSetCommand_instances, "m", _EntraGroupMemberSetCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _EntraGroupMemberSetCommand_instances, "m", _EntraGroupMemberSetCommand_initTypes).call(this);
|
|
29
29
|
}
|
|
30
30
|
async commandAction(logger, args) {
|
|
31
31
|
try {
|
|
32
32
|
if (this.verbose) {
|
|
33
|
-
await logger.logToStderr(`Adding
|
|
33
|
+
await logger.logToStderr(`Adding member(s) ${args.options.ids || args.options.userNames} to role ${args.options.role} of group ${args.options.groupId || args.options.groupDisplayName}...`);
|
|
34
34
|
}
|
|
35
35
|
const groupId = await this.getGroupId(logger, args.options);
|
|
36
36
|
const userIds = await this.getUserIds(logger, args.options);
|
|
@@ -66,7 +66,7 @@ class EntraGroupUserSetCommand extends GraphCommand {
|
|
|
66
66
|
const userIdsToRemove = [];
|
|
67
67
|
const currentRole = options.role === 'Member' ? 'owners' : 'members';
|
|
68
68
|
if (this.verbose) {
|
|
69
|
-
await logger.logToStderr(`Removing
|
|
69
|
+
await logger.logToStderr(`Removing members from the old role '${currentRole}'.`);
|
|
70
70
|
}
|
|
71
71
|
for (let i = 0; i < userIds.length; i += 20) {
|
|
72
72
|
const userIdsBatch = userIds.slice(i, i + 20);
|
|
@@ -153,7 +153,7 @@ class EntraGroupUserSetCommand extends GraphCommand {
|
|
|
153
153
|
return requestOptions;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
_EntraGroupMemberSetCommand_instances = new WeakSet(), _EntraGroupMemberSetCommand_initTelemetry = function _EntraGroupMemberSetCommand_initTelemetry() {
|
|
157
157
|
this.telemetry.push((args) => {
|
|
158
158
|
Object.assign(this.telemetryProperties, {
|
|
159
159
|
groupId: typeof args.options.groupId !== 'undefined',
|
|
@@ -162,7 +162,7 @@ _EntraGroupUserSetCommand_instances = new WeakSet(), _EntraGroupUserSetCommand_i
|
|
|
162
162
|
userNames: typeof args.options.userNames !== 'undefined'
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
|
-
},
|
|
165
|
+
}, _EntraGroupMemberSetCommand_initOptions = function _EntraGroupMemberSetCommand_initOptions() {
|
|
166
166
|
this.options.unshift({
|
|
167
167
|
option: '-i, --groupId [groupId]'
|
|
168
168
|
}, {
|
|
@@ -175,7 +175,7 @@ _EntraGroupUserSetCommand_instances = new WeakSet(), _EntraGroupUserSetCommand_i
|
|
|
175
175
|
option: '-r, --role <role>',
|
|
176
176
|
autocomplete: this.roleValues
|
|
177
177
|
});
|
|
178
|
-
},
|
|
178
|
+
}, _EntraGroupMemberSetCommand_initValidators = function _EntraGroupMemberSetCommand_initValidators() {
|
|
179
179
|
this.validators.push(async (args) => {
|
|
180
180
|
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
181
181
|
return `${args.options.groupId} is not a valid GUID for option groupId.`;
|
|
@@ -197,10 +197,10 @@ _EntraGroupUserSetCommand_instances = new WeakSet(), _EntraGroupUserSetCommand_i
|
|
|
197
197
|
}
|
|
198
198
|
return true;
|
|
199
199
|
});
|
|
200
|
-
},
|
|
200
|
+
}, _EntraGroupMemberSetCommand_initOptionSets = function _EntraGroupMemberSetCommand_initOptionSets() {
|
|
201
201
|
this.optionSets.push({ options: ['groupId', 'groupDisplayName'] }, { options: ['ids', 'userNames'] });
|
|
202
|
-
},
|
|
202
|
+
}, _EntraGroupMemberSetCommand_initTypes = function _EntraGroupMemberSetCommand_initTypes() {
|
|
203
203
|
this.types.string.push('groupId', 'groupDisplayName', 'ids', 'userNames', 'role');
|
|
204
204
|
};
|
|
205
|
-
export default new
|
|
206
|
-
//# sourceMappingURL=group-
|
|
205
|
+
export default new EntraGroupMemberSetCommand();
|
|
206
|
+
//# sourceMappingURL=group-member-set.js.map
|
|
@@ -41,9 +41,9 @@ export default {
|
|
|
41
41
|
GROUP_LIST: `${prefix} group list`,
|
|
42
42
|
GROUP_REMOVE: `${prefix} group remove`,
|
|
43
43
|
GROUP_SET: `${prefix} group set`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
GROUP_MEMBER_ADD: `${prefix} group member add`,
|
|
45
|
+
GROUP_MEMBER_LIST: `${prefix} group member list`,
|
|
46
|
+
GROUP_MEMBER_SET: `${prefix} group member set`,
|
|
47
47
|
GROUPSETTING_ADD: `${prefix} groupsetting add`,
|
|
48
48
|
GROUPSETTING_GET: `${prefix} groupsetting get`,
|
|
49
49
|
GROUPSETTING_LIST: `${prefix} groupsetting list`,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Global from '/docs/cmd/_global.mdx';
|
|
2
|
+
|
|
3
|
+
# entra group member add
|
|
4
|
+
|
|
5
|
+
Adds a member to a Microsoft Entra ID group
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
m365 entra group member add [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Options
|
|
14
|
+
|
|
15
|
+
```md definition-list
|
|
16
|
+
`-i, --groupId [groupId]`
|
|
17
|
+
: The ID of the Microsoft Entra group. Specify `groupId` or `groupDisplayName` but not both.
|
|
18
|
+
|
|
19
|
+
`-n, --groupDisplayName [groupDisplayName]`
|
|
20
|
+
: The display name of the Microsoft Entra group. Specify `groupId` or `groupDisplayName` but not both.
|
|
21
|
+
|
|
22
|
+
`--ids [ids]`
|
|
23
|
+
: Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify either `ids` or `userNames` but not both.
|
|
24
|
+
|
|
25
|
+
`--userNames [userNames]`
|
|
26
|
+
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both.
|
|
27
|
+
|
|
28
|
+
`-r, --role <role>`
|
|
29
|
+
: The role to be assigned to the new users. Valid values: `Owner`, `Member`.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<Global />
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
Add a single member specified by ID as a member to a group specified by display name.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
m365 entra group member add --groupDisplayName Developers --ids 098b9f52-f48c-4401-819f-29c33794c3f5 --role Member
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Add multiple members specified by ID as members to a group specified by ID.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --ids "098b9f52-f48c-4401-819f-29c33794c3f5,f1e06e31-3abf-4746-83c2-1513d71f38b8" --role Member
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add a single member specified by UPN as an owner to a group specified by display name.
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
m365 entra group member add --groupDisplayName Developers --userNames john.doe@contoso.com --role Owner
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Adds multiple members specified by UPN as owners to a group specified by ID.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
m365 entra group member add --groupId a03c0c35-ef9a-419b-8cab-f89e0a8d2d2a --userNames "john.doe@contoso.com,adele.vance@contoso.com" --role Owner
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Response
|
|
61
|
+
|
|
62
|
+
The command won't return a response on success.
|
|
@@ -2,14 +2,14 @@ import Global from '/docs/cmd/_global.mdx';
|
|
|
2
2
|
import Tabs from '@theme/Tabs';
|
|
3
3
|
import TabItem from '@theme/TabItem';
|
|
4
4
|
|
|
5
|
-
# entra group
|
|
5
|
+
# entra group member list
|
|
6
6
|
|
|
7
|
-
Lists
|
|
7
|
+
Lists members of a specific Entra group
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
m365 entra group
|
|
12
|
+
m365 entra group member list [options]
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Alias
|
|
@@ -28,13 +28,13 @@ m365 aad group user list [options]
|
|
|
28
28
|
: The display name of the Entra group. Specify `groupId` or `groupName` but not both.
|
|
29
29
|
|
|
30
30
|
`-r, --role [role]`
|
|
31
|
-
: Filter the results to only
|
|
31
|
+
: Filter the results to only members with the given role: `Owner`, `Member`.
|
|
32
32
|
|
|
33
33
|
`-p, --properties [properties]`
|
|
34
34
|
: Comma-separated list of properties to retrieve.
|
|
35
35
|
|
|
36
36
|
`-f, --filter [filter]`
|
|
37
|
-
: OData filter to use to query the list of
|
|
37
|
+
: OData filter to use to query the list of members with.
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
<Global />
|
|
@@ -45,34 +45,34 @@ When the `properties` option includes values with a `/`, for example: `manager/d
|
|
|
45
45
|
|
|
46
46
|
## Examples
|
|
47
47
|
|
|
48
|
-
List all group
|
|
48
|
+
List all group members from a group specified by ID.
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
m365 entra group
|
|
51
|
+
m365 entra group member list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
List all owners from a group specified by display name.
|
|
55
55
|
|
|
56
56
|
```sh
|
|
57
|
-
m365 entra group
|
|
57
|
+
m365 entra group member list --groupName Developers --role Owner
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
List all group
|
|
60
|
+
List all group members from a group specified by name. For each one return the display name, e-mail address, and manager display name.
|
|
61
61
|
|
|
62
62
|
```sh
|
|
63
|
-
m365 entra group
|
|
63
|
+
m365 entra group member list --groupName Developers --properties "displayName,mail,manager/displayName"
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
List all group
|
|
66
|
+
List all group members from a group specified by name. For each one return the display name, e-mail address, and manager information.
|
|
67
67
|
|
|
68
68
|
```sh
|
|
69
|
-
m365 entra group
|
|
69
|
+
m365 entra group member list --groupName Developers --properties "displayName,mail,manager/*"
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
List all group members that are guest
|
|
72
|
+
List all group members that are guest members.
|
|
73
73
|
|
|
74
74
|
```sh
|
|
75
|
-
m365 entra group
|
|
75
|
+
m365 entra group member list --groupName Developers --filter "userType eq 'Guest'"
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
## Response
|