@pnp/cli-microsoft365 6.3.0-beta.82f99fc → 6.3.0-beta.98b4bc2

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.
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _AadUserAddCommand_instances, _AadUserAddCommand_initTelemetry, _AadUserAddCommand_initOptions, _AadUserAddCommand_initValidators, _AadUserAddCommand_initOptionSets, _AadUserAddCommand_initTypes;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const validation_1 = require("../../../../utils/validation");
20
+ const GraphCommand_1 = require("../../../base/GraphCommand");
21
+ const commands_1 = require("../../commands");
22
+ class AadUserAddCommand extends GraphCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.USER_ADD;
25
+ }
26
+ get description() {
27
+ return 'Creates a new user';
28
+ }
29
+ constructor() {
30
+ super();
31
+ _AadUserAddCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initTelemetry).call(this);
33
+ __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initOptions).call(this);
34
+ __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initValidators).call(this);
35
+ __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initOptionSets).call(this);
36
+ __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initTypes).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ var _a, _b, _c;
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ if (this.verbose) {
42
+ logger.logToStderr(`Adding user to AAD with displayName ${args.options.displayName} and userPrincipalName ${args.options.userName}`);
43
+ }
44
+ try {
45
+ const requestOptions = {
46
+ url: `${this.resource}/v1.0/users`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json',
51
+ data: {
52
+ accountEnabled: (_a = args.options.accountEnabled) !== null && _a !== void 0 ? _a : true,
53
+ displayName: args.options.displayName,
54
+ userPrincipalName: args.options.userName,
55
+ mailNickName: (_b = args.options.mailNickname) !== null && _b !== void 0 ? _b : args.options.userName.split('@')[0],
56
+ passwordProfile: {
57
+ forceChangePasswordNextSignIn: args.options.forceChangePasswordNextSignIn || false,
58
+ forceChangePasswordNextSignInWithMfa: args.options.forceChangePasswordNextSignInWithMfa || false,
59
+ password: (_c = args.options.password) !== null && _c !== void 0 ? _c : this.generatePassword()
60
+ },
61
+ givenName: args.options.firstName,
62
+ surName: args.options.lastName,
63
+ usageLocation: args.options.usageLocation,
64
+ officeLocation: args.options.officeLocation,
65
+ jobTitle: args.options.jobTitle,
66
+ companyName: args.options.companyName,
67
+ department: args.options.department,
68
+ preferredLanguage: args.options.preferredLanguage
69
+ }
70
+ };
71
+ const user = yield request_1.default.post(requestOptions);
72
+ user.password = requestOptions.data.passwordProfile.password;
73
+ if (args.options.managerUserId || args.options.managerUserName) {
74
+ const managerRequestOptions = {
75
+ url: `${this.resource}/v1.0/users/${user.id}/manager/$ref`,
76
+ headers: {
77
+ accept: 'application/json;odata.metadata=none'
78
+ },
79
+ data: {
80
+ '@odata.id': `${this.resource}/v1.0/users/${args.options.managerUserId || args.options.managerUserName}`
81
+ }
82
+ };
83
+ yield request_1.default.put(managerRequestOptions);
84
+ }
85
+ logger.log(user);
86
+ }
87
+ catch (err) {
88
+ this.handleRejectedODataJsonPromise(err);
89
+ }
90
+ });
91
+ }
92
+ /**
93
+ * Generate a password with at least: one digit, one lowercase chracter, one uppercase character and special character.
94
+ */
95
+ generatePassword() {
96
+ const numberChars = '0123456789';
97
+ const upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
98
+ const lowerChars = 'abcdefghijklmnopqrstuvwxyz';
99
+ const specialChars = '-_@%$#*&';
100
+ const allChars = numberChars + upperChars + lowerChars + specialChars;
101
+ let randPasswordArray = Array(15);
102
+ randPasswordArray[0] = numberChars;
103
+ randPasswordArray[1] = upperChars;
104
+ randPasswordArray[2] = lowerChars;
105
+ randPasswordArray[3] = specialChars;
106
+ randPasswordArray = randPasswordArray.fill(allChars, 4);
107
+ const randomCharacterArray = randPasswordArray.map((charSet) => charSet[Math.floor(Math.random() * charSet.length)]);
108
+ return this.shuffleArray(randomCharacterArray).join('');
109
+ }
110
+ shuffleArray(characterArray) {
111
+ for (let i = characterArray.length - 1; i > 0; i--) {
112
+ const j = Math.floor(Math.random() * (i + 1));
113
+ const temp = characterArray[i];
114
+ characterArray[i] = characterArray[j];
115
+ characterArray[j] = temp;
116
+ }
117
+ return characterArray;
118
+ }
119
+ }
120
+ _AadUserAddCommand_instances = new WeakSet(), _AadUserAddCommand_initTelemetry = function _AadUserAddCommand_initTelemetry() {
121
+ this.telemetry.push((args) => {
122
+ Object.assign(this.telemetryProperties, {
123
+ accountEnabled: typeof args.options.accountEnabled !== 'undefined',
124
+ mailNickname: typeof args.options.mailNickname !== 'undefined',
125
+ password: typeof args.options.password !== 'undefined',
126
+ firstName: typeof args.options.firstName !== 'undefined',
127
+ lastName: typeof args.options.lastName !== 'undefined',
128
+ forceChangePasswordNextSignIn: !!args.options.forceChangePasswordNextSignIn,
129
+ forceChangePasswordNextSignInWithMfa: !!args.options.forceChangePasswordNextSignInWithMfa,
130
+ usageLocation: typeof args.options.usageLocation !== 'undefined',
131
+ officeLocation: typeof args.options.officeLocation !== 'undefined',
132
+ jobTitle: typeof args.options.jobTitle !== 'undefined',
133
+ companyName: typeof args.options.companyName !== 'undefined',
134
+ department: typeof args.options.department !== 'undefined',
135
+ preferredLanguage: typeof args.options.preferredLanguage !== 'undefined',
136
+ managerUserId: typeof args.options.managerUserId !== 'undefined',
137
+ managerUserName: typeof args.options.managerUserName !== 'undefined'
138
+ });
139
+ });
140
+ }, _AadUserAddCommand_initOptions = function _AadUserAddCommand_initOptions() {
141
+ this.options.unshift({
142
+ option: '--displayName <displayName>'
143
+ }, {
144
+ option: '--userName <userName>'
145
+ }, {
146
+ option: '--accountEnabled [accountEnabled]',
147
+ autocomplete: ['true', 'false']
148
+ }, {
149
+ option: '--mailNickname [mailNickname]'
150
+ }, {
151
+ option: '--password [password]'
152
+ }, {
153
+ option: '--firstName [firstName]'
154
+ }, {
155
+ option: '--lastName [lastName]'
156
+ }, {
157
+ option: '--forceChangePasswordNextSignIn'
158
+ }, {
159
+ option: '--forceChangePasswordNextSignInWithMfa'
160
+ }, {
161
+ option: '--usageLocation [usageLocation]'
162
+ }, {
163
+ option: '--officeLocation [officeLocation]'
164
+ }, {
165
+ option: '--jobTitle [jobTitle]'
166
+ }, {
167
+ option: '--companyName [companyName]'
168
+ }, {
169
+ option: '--department [department]'
170
+ }, {
171
+ option: '--preferredLanguage [preferredLanguage]'
172
+ }, {
173
+ option: '--managerUserId [managerUserId]'
174
+ }, {
175
+ option: '--managerUserName [managerUserName]'
176
+ });
177
+ }, _AadUserAddCommand_initValidators = function _AadUserAddCommand_initValidators() {
178
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
179
+ if (!validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
180
+ return `${args.options.userName} is not a valid userName`;
181
+ }
182
+ if (args.options.usageLocation) {
183
+ const regex = new RegExp('^[a-zA-Z]{2}$');
184
+ if (!regex.test(args.options.usageLocation)) {
185
+ return `'${args.options.usageLocation}' is not a valid usageLocation.`;
186
+ }
187
+ }
188
+ if (args.options.preferredLanguage && args.options.preferredLanguage.length < 2) {
189
+ return `'${args.options.preferredLanguage}' is not a valid preferredLanguage`;
190
+ }
191
+ if (args.options.firstName && args.options.firstName.length > 64) {
192
+ return `The maximum amount of characters for 'firstName' is 64.`;
193
+ }
194
+ if (args.options.lastName && args.options.lastName.length > 64) {
195
+ return `The maximum amount of characters for 'lastName' is 64.`;
196
+ }
197
+ if (args.options.jobTitle && args.options.jobTitle.length > 128) {
198
+ return `The maximum amount of characters for 'jobTitle' is 128.`;
199
+ }
200
+ if (args.options.companyName && args.options.companyName.length > 64) {
201
+ return `The maximum amount of characters for 'companyName' is 64.`;
202
+ }
203
+ if (args.options.department && args.options.department.length > 64) {
204
+ return `The maximum amount of characters for 'department' is 64.`;
205
+ }
206
+ if (args.options.managerUserName && !validation_1.validation.isValidUserPrincipalName(args.options.managerUserName)) {
207
+ return `'${args.options.managerUserName}' is not a valid user principal name.`;
208
+ }
209
+ if (args.options.managerUserId && !validation_1.validation.isValidGuid(args.options.managerUserId)) {
210
+ return `'${args.options.managerUserId}' is not a valid GUID.`;
211
+ }
212
+ return true;
213
+ }));
214
+ }, _AadUserAddCommand_initOptionSets = function _AadUserAddCommand_initOptionSets() {
215
+ this.optionSets.push({
216
+ options: ['managerUserId', 'managerUserName'],
217
+ runsWhen: (args) => args.options.managerId || args.options.managerUserName
218
+ });
219
+ }, _AadUserAddCommand_initTypes = function _AadUserAddCommand_initTypes() {
220
+ this.types.boolean.push('accountEnabled');
221
+ };
222
+ module.exports = new AadUserAddCommand();
223
+ //# sourceMappingURL=user-add.js.map
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _AadUserLicenseListCommand_instances, _AadUserLicenseListCommand_initTelemetry, _AadUserLicenseListCommand_initOptions, _AadUserLicenseListCommand_initValidators, _AadUserLicenseListCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const accessToken_1 = require("../../../../utils/accessToken");
19
+ const odata_1 = require("../../../../utils/odata");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const GraphCommand_1 = require("../../../base/GraphCommand");
22
+ const commands_1 = require("../../commands");
23
+ const Auth_1 = require("../../../../Auth");
24
+ class AadUserLicenseListCommand extends GraphCommand_1.default {
25
+ get name() {
26
+ return commands_1.default.USER_LICENSE_LIST;
27
+ }
28
+ get description() {
29
+ return 'Lists the license details for a given user';
30
+ }
31
+ defaultProperties() {
32
+ return ['id', 'skuId', 'skuPartNumber'];
33
+ }
34
+ constructor() {
35
+ super();
36
+ _AadUserLicenseListCommand_instances.add(this);
37
+ __classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initTelemetry).call(this);
38
+ __classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initOptions).call(this);
39
+ __classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initValidators).call(this);
40
+ __classPrivateFieldGet(this, _AadUserLicenseListCommand_instances, "m", _AadUserLicenseListCommand_initOptionSets).call(this);
41
+ }
42
+ commandAction(logger, args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken);
45
+ if (isAppOnlyAccessToken && !args.options.userId && !args.options.userName) {
46
+ this.handleError(`Specify at least 'userId' or 'userName' when using application permissions.`);
47
+ }
48
+ if (this.verbose) {
49
+ logger.logToStderr(`Retrieving licenses from user: ${args.options.userId || args.options.userName || 'current user'}.`);
50
+ }
51
+ let requestUrl = `${this.resource}/v1.0/`;
52
+ if (args.options.userId || args.options.userName) {
53
+ requestUrl += `users/${args.options.userId || args.options.userName}`;
54
+ }
55
+ else {
56
+ requestUrl += 'me';
57
+ }
58
+ requestUrl += '/licenseDetails';
59
+ try {
60
+ const items = yield odata_1.odata.getAllItems(requestUrl);
61
+ logger.log(items);
62
+ }
63
+ catch (err) {
64
+ this.handleRejectedODataJsonPromise(err);
65
+ }
66
+ });
67
+ }
68
+ }
69
+ _AadUserLicenseListCommand_instances = new WeakSet(), _AadUserLicenseListCommand_initTelemetry = function _AadUserLicenseListCommand_initTelemetry() {
70
+ this.telemetry.push((args) => {
71
+ Object.assign(this.telemetryProperties, {
72
+ userId: typeof args.options.userId !== 'undefined',
73
+ userName: typeof args.options.userName !== 'undefined'
74
+ });
75
+ });
76
+ }, _AadUserLicenseListCommand_initOptions = function _AadUserLicenseListCommand_initOptions() {
77
+ this.options.unshift({
78
+ option: '--userId [userId]'
79
+ }, {
80
+ option: '--userName [userName]'
81
+ });
82
+ }, _AadUserLicenseListCommand_initValidators = function _AadUserLicenseListCommand_initValidators() {
83
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
84
+ if (args.options.userId && !validation_1.validation.isValidGuid(args.options.userId)) {
85
+ return `${args.options.userId} is not a valid GUID`;
86
+ }
87
+ if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
88
+ return `${args.options.userName} is not a valid user principal name (UPN)`;
89
+ }
90
+ return true;
91
+ }));
92
+ }, _AadUserLicenseListCommand_initOptionSets = function _AadUserLicenseListCommand_initOptionSets() {
93
+ this.optionSets.push({
94
+ options: ['userId', 'userName'],
95
+ runsWhen: (args) => args.options.userId || args.options.userName
96
+ });
97
+ };
98
+ module.exports = new AadUserLicenseListCommand();
99
+ //# sourceMappingURL=user-license-list.js.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const odata_1 = require("../../../../utils/odata");
13
+ const GraphCommand_1 = require("../../../base/GraphCommand");
14
+ const commands_1 = require("../../commands");
15
+ class AadUserRecycleBinItemListCommand extends GraphCommand_1.default {
16
+ get name() {
17
+ return commands_1.default.USER_RECYCLEBINITEM_LIST;
18
+ }
19
+ get description() {
20
+ return 'Lists users from the recycle bin in the current tenant';
21
+ }
22
+ defaultProperties() {
23
+ return ['id', 'displayName', 'userPrincipalName'];
24
+ }
25
+ commandAction(logger) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ if (this.verbose) {
28
+ logger.logToStderr('Retrieving users from the recycle bin...');
29
+ }
30
+ try {
31
+ const users = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/directory/deletedItems/microsoft.graph.user`);
32
+ logger.log(users);
33
+ }
34
+ catch (err) {
35
+ this.handleRejectedODataJsonPromise(err);
36
+ }
37
+ });
38
+ }
39
+ }
40
+ module.exports = new AadUserRecycleBinItemListCommand();
41
+ //# sourceMappingURL=user-recyclebinitem-list.js.map
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _AadUserRemoveCommand_instances, _AadUserRemoveCommand_initTelemetry, _AadUserRemoveCommand_initOptions, _AadUserRemoveCommand_initOptionSets, _AadUserRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const commands_1 = require("../../commands");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const Cli_1 = require("../../../../cli/Cli");
22
+ const GraphCommand_1 = require("../../../base/GraphCommand");
23
+ class AadUserRemoveCommand extends GraphCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.USER_REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Removes a specific user';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _AadUserRemoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _AadUserRemoveCommand_instances, "m", _AadUserRemoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _AadUserRemoveCommand_instances, "m", _AadUserRemoveCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _AadUserRemoveCommand_instances, "m", _AadUserRemoveCommand_initValidators).call(this);
36
+ __classPrivateFieldGet(this, _AadUserRemoveCommand_instances, "m", _AadUserRemoveCommand_initOptionSets).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Removing user '${args.options.id || args.options.userName}'...`);
42
+ }
43
+ if (args.options.confirm) {
44
+ yield this.deleteUser(args);
45
+ }
46
+ else {
47
+ const result = yield Cli_1.Cli.prompt({
48
+ type: 'confirm',
49
+ name: 'continue',
50
+ default: false,
51
+ message: `Are you sure you want to remove user '${args.options.id || args.options.userName}'?`
52
+ });
53
+ if (result.continue) {
54
+ yield this.deleteUser(args);
55
+ }
56
+ }
57
+ });
58
+ }
59
+ deleteUser(args) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ try {
62
+ const requestOptions = {
63
+ url: `${this.resource}/v1.0/users/${args.options.id || args.options.userName}`,
64
+ headers: {
65
+ accept: 'application/json;odata.metadata=none'
66
+ },
67
+ responseType: 'json'
68
+ };
69
+ yield request_1.default.delete(requestOptions);
70
+ }
71
+ catch (err) {
72
+ this.handleRejectedODataJsonPromise(err);
73
+ }
74
+ });
75
+ }
76
+ }
77
+ _AadUserRemoveCommand_instances = new WeakSet(), _AadUserRemoveCommand_initTelemetry = function _AadUserRemoveCommand_initTelemetry() {
78
+ this.telemetry.push((args) => {
79
+ Object.assign(this.telemetryProperties, {
80
+ id: typeof args.options.id !== 'undefined',
81
+ userName: typeof args.options.userName !== 'undefined',
82
+ confirm: !!args.options.confirm
83
+ });
84
+ });
85
+ }, _AadUserRemoveCommand_initOptions = function _AadUserRemoveCommand_initOptions() {
86
+ this.options.unshift({
87
+ option: '--id [id]'
88
+ }, {
89
+ option: '--userName [userName]'
90
+ }, {
91
+ option: '--confirm'
92
+ });
93
+ }, _AadUserRemoveCommand_initOptionSets = function _AadUserRemoveCommand_initOptionSets() {
94
+ this.optionSets.push({ options: ['id', 'userName'] });
95
+ }, _AadUserRemoveCommand_initValidators = function _AadUserRemoveCommand_initValidators() {
96
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
97
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
98
+ return `${args.options.id} is not a valid GUID`;
99
+ }
100
+ if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
101
+ return `${args.options.userName} is not a valid user principal name (UPN)`;
102
+ }
103
+ return true;
104
+ }));
105
+ };
106
+ module.exports = new AadUserRemoveCommand();
107
+ //# sourceMappingURL=user-remove.js.map
@@ -55,13 +55,17 @@ exports.default = {
55
55
  SITECLASSIFICATION_SET: `${prefix} siteclassification set`,
56
56
  SP_ADD: `${prefix} sp add`,
57
57
  SP_GET: `${prefix} sp get`,
58
+ USER_ADD: `${prefix} user add`,
58
59
  USER_GET: `${prefix} user get`,
59
60
  USER_GUEST_ADD: `${prefix} user guest add`,
60
61
  USER_HIBP: `${prefix} user hibp`,
62
+ USER_LICENSE_LIST: `${prefix} user license list`,
61
63
  USER_LIST: `${prefix} user list`,
62
64
  USER_PASSWORD_VALIDATE: `${prefix} user password validate`,
63
65
  USER_RECYCLEBINITEM_CLEAR: `${prefix} user recyclebinitem clear`,
66
+ USER_RECYCLEBINITEM_LIST: `${prefix} user recyclebinitem list`,
64
67
  USER_RECYCLEBINITEM_REMOVE: `${prefix} user recyclebinitem remove`,
68
+ USER_REMOVE: `${prefix} user remove`,
65
69
  USER_SET: `${prefix} user set`,
66
70
  USER_SIGNIN_LIST: `${prefix} user signin list`
67
71
  };
@@ -0,0 +1,168 @@
1
+ # aad user add
2
+
3
+ Creates a new user
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 aad user add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--displayName <displayName>`
14
+ : The name to display in the address book for the user.
15
+
16
+ `--userName <userName>`
17
+ : The user principal name (someuser@contoso.com).
18
+
19
+ `--accountEnabled [accountEnabled]`
20
+ : Whether the account is enabled. Possible values: `true`, `false`. Default value is `true`.
21
+
22
+ `--mailNickname [mailNickname]`
23
+ : The mail alias for the user. By default this value will be extracted from `userName`.
24
+
25
+ `--password [password]`
26
+ : The password for the user. When not specified, a password will be generated.
27
+
28
+ `--firstName [firstName]`
29
+ : The given name (first name) of the user. Maximum length is 64 characters.
30
+
31
+ `--lastName [lastName]`
32
+ : The user's surname (family name or last name). Maximum length is 64 characters.
33
+
34
+ `--forceChangePasswordNextSignIn`
35
+ : Whether the user should change his/her password on the next login.
36
+
37
+ `--forceChangePasswordNextSignInWithMfa`
38
+ : Whether the user should change his/her password on the next login and setup MFA.
39
+
40
+ `--usageLocation [usageLocation]`
41
+ : A two letter [country code](https://learn.microsoft.com/en-us/partner-center/commercial-marketplace-co-sell-location-codes#country-and-region-codes) (ISO standard 3166). Required for users that will be assigned licenses.
42
+
43
+ `--officeLocation [officeLocation]`
44
+ : The office location in the user's place of business.
45
+
46
+ `--jobTitle [jobTitle]`
47
+ : The user's job title. Maximum length is 128 characters.
48
+
49
+ `--companyName [companyName]`
50
+ : The company name which the user is associated. The maximum length is 64 characters.
51
+
52
+ `--department [department]`
53
+ : The name for the department in which the user works. Maximum length is 64 characters.
54
+
55
+ `--preferredLanguage [preferredLanguage]`
56
+ : The preferred language for the user. Should follow [ISO 639-1 Code](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a). Example: `en-US`.
57
+
58
+ `--managerUserId [managerUserId]`
59
+ : User ID of the user's manager. Specify `managerUserId` or `managerUserName` but not both.
60
+
61
+ `--managerUserName [managerUserName]`
62
+ : User principal name of the manager. Specify `managerUserId` or `managerUserName` but not both.
63
+
64
+ --8<-- "docs/cmd/_global.md"
65
+
66
+ ## Remarks
67
+
68
+ !!! important
69
+ To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator
70
+
71
+ !!! note
72
+ After running this command, it may take a minute before the user is effectively created in the tenant.
73
+
74
+ ## Examples
75
+
76
+ Create a user and let him/her update the password at first login
77
+
78
+ ```sh
79
+ m365 aad user add --displayName "John Doe" --userName "john.doe@contoso.com" --password "SomePassw0rd" --forceChangePasswordNextSignIn
80
+ ```
81
+
82
+ Create a user with job information
83
+
84
+ ```sh
85
+ m365 aad user add --displayName "John Doe" --userName "john.doe@contoso.com" --password "SomePassw0rd" --firstName John --lastName Doe --jobTitle "Sales Manager" --companyName Contoso --department Sales --officeLocation Vosselaar --forceChangePasswordNextSignIn
86
+ ```
87
+
88
+ Create a user with language information
89
+
90
+ ```sh
91
+ m365 aad user add --displayName "John Doe" --userName "john.doe@contoso.com" --preferredLanguage "nl-BE" --usageLocation BE --forceChangePasswordNextSignIn
92
+ ```
93
+
94
+ Create a user with a manager
95
+
96
+ ```sh
97
+ m365 aad user add --displayName "John Doe" --userName "john.doe@contoso.com" --managerUserName "adele@contoso.com"
98
+ ```
99
+
100
+ ## Response
101
+
102
+ === "JSON"
103
+
104
+ ```json
105
+ {
106
+ "id": "990e2425-f595-43bc-85ed-b89a44093793",
107
+ "businessPhones": [],
108
+ "displayName": "John Doe",
109
+ "givenName": "John",
110
+ "jobTitle": "Sales Manager",
111
+ "mail": null,
112
+ "mobilePhone": null,
113
+ "officeLocation": "Vosselaar",
114
+ "preferredLanguage": "nl-BE",
115
+ "surname": "Doe",
116
+ "userPrincipalName": "john.doe@contoso.com",
117
+ "password": "SomePassw0rd"
118
+ }
119
+ ```
120
+
121
+ === "Text"
122
+
123
+ ```text
124
+ businessPhones : []
125
+ displayName : John Doe
126
+ givenName : John
127
+ id : 990e2425-f595-43bc-85ed-b89a44093793
128
+ jobTitle : Sales Manager
129
+ mail : null
130
+ mobilePhone : null
131
+ officeLocation : Vosselaar
132
+ password : SomePassw0rd
133
+ preferredLanguage: nl-BE
134
+ surname : Doe
135
+ userPrincipalName: john.doe@contoso.com
136
+ ```
137
+
138
+ === "CSV"
139
+
140
+ ```csv
141
+ id,businessPhones,displayName,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,password
142
+ 990e2425-f595-43bc-85ed-b89a44093793,[],John Doe,John,Sales Manager,,,Vosselaar,nl-BE,Doe,john.doe@contoso.com,SomePassw0rd
143
+ ```
144
+
145
+ === "Markdown"
146
+
147
+ ```md
148
+ # aad user add --displayName "John Doe" --userName "john.doe@contoso.com" --password "SomePassw0rd" --firstName "John" --lastName "Doe" --jobTitle "Sales Manager" --officeLocation "Vosselaar" --preferredLanguage "nl-BE"
149
+
150
+ Date: 16/02/2023
151
+
152
+ ## John Doe (990e2425-f595-43bc-85ed-b89a44093793)
153
+
154
+ Property | Value
155
+ ---------|-------
156
+ id | 990e2425-f595-43bc-85ed-b89a44093793
157
+ businessPhones | []
158
+ displayName | John Doe
159
+ givenName | John
160
+ jobTitle | Sales Manager
161
+ mail | null
162
+ mobilePhone | null
163
+ officeLocation | Vosselaar
164
+ preferredLanguage | nl-BE
165
+ surname | Doe
166
+ userPrincipalName | john.doe@contoso.com
167
+ password | SomePassw0rd
168
+ ```
@@ -0,0 +1,98 @@
1
+ # aad user license list
2
+
3
+ Lists the license details for a given user
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 aad user license list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--userId [userId]`
14
+ : The ID of the user. Specify either `userId` or `userName` but not both.
15
+
16
+ `--userName [userName]`
17
+ : User principal name of the user. Specify either `userId` or `userName` but not both.
18
+
19
+ --8<-- "docs/cmd/_global.md"
20
+
21
+ ## Remarks
22
+
23
+ !!! tip
24
+ If you don't specify any option, the command will list the license details of the current logged in user. This does not work when using application permissions.
25
+
26
+ ## Examples
27
+
28
+ List license details of the current logged in user.
29
+
30
+ ```sh
31
+ m365 aad user license list
32
+ ```
33
+
34
+ List license details of a specific user by its UPN.
35
+
36
+ ```sh
37
+ m365 aad user license list --userName john.doe@contoso.com
38
+ ```
39
+
40
+ List license details of a specific user by its ID.
41
+
42
+ ```sh
43
+ m365 aad user license list --userId 59f80e08-24b1-41f8-8586-16765fd830d3
44
+ ```
45
+
46
+ ## Response
47
+
48
+ === "JSON"
49
+
50
+ ```json
51
+ [
52
+ {
53
+ "id": "x4s03usaBkSMs5fbAhyttK6cK8RP6rdKlxeBV2I1zKw",
54
+ "skuId": "c42b9cae-ea4f-4ab7-9717-81576235ccac",
55
+ "skuPartNumber": "DEVELOPERPACK_E5",
56
+ "servicePlans": [
57
+ {
58
+ "servicePlanId": "7547a3fe-08ee-4ccb-b430-5077c5041653",
59
+ "servicePlanName": "YAMMER_ENTERPRISE",
60
+ "provisioningStatus": "Success",
61
+ "appliesTo": "User"
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ ```
67
+
68
+ === "Text"
69
+
70
+ ```text
71
+ id : x4s03usaBkSMs5fbAhyttK6cK8RP6rdKlxeBV2I1zKw
72
+ skuId : c42b9cae-ea4f-4ab7-9717-81576235ccac
73
+ skuPartNumber: DEVELOPERPACK_E5
74
+ ```
75
+
76
+ === "CSV"
77
+
78
+ ```csv
79
+ id,skuId,skuPartNumber
80
+ x4s03usaBkSMs5fbAhyttK6cK8RP6rdKlxeBV2I1zKw,c42b9cae-ea4f-4ab7-9717-81576235ccac,DEVELOPERPACK_E5
81
+ ```
82
+
83
+ === "Markdown"
84
+
85
+ ```md
86
+ # aad user license list --userId "0c9c625f-faa9-4c3b-8cd8-d874b869f78c"
87
+
88
+ Date: 2/19/2023
89
+
90
+ ## x4s03usaBkSMs5fbAhyttK6cK8RP6rdKlxeBV2I1zKw
91
+
92
+ Property | Value
93
+ ---------|-------
94
+ id | x4s03usaBkSMs5fbAhyttK6cK8RP6rdKlxeBV2I1zKw
95
+ skuId | c42b9cae-ea4f-4ab7-9717-81576235ccac
96
+ skuPartNumber | DEVELOPERPACK\_E5
97
+ servicePlans | [{"servicePlanId":"7547a3fe-08ee-4ccb-b430-5077c5041653","servicePlanName":"YAMMER\_ENTERPRISE","provisioningStatus":"Success","appliesTo":"User"}]
98
+ ```
@@ -18,7 +18,7 @@ m365 aad user recyclebinitem clear [options]
18
18
  ## Remarks
19
19
 
20
20
  !!! important
21
- To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator
21
+ To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator.
22
22
 
23
23
  !!! note
24
24
  After running this command, it may take a minute before all deleted users are effectively removed from the tenant.
@@ -0,0 +1,82 @@
1
+ # aad user recyclebinitem list
2
+
3
+ Lists users from the recycle bin in the current tenant
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 aad user recyclebinitem list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ --8<-- "docs/cmd/_global.md"
14
+
15
+ ## Examples
16
+
17
+ List all removed users
18
+
19
+ ```sh
20
+ m365 aad user recyclebinitem list
21
+ ```
22
+
23
+ ## Response
24
+
25
+ === "JSON"
26
+
27
+ ```json
28
+ [
29
+ {
30
+ "businessPhones": [],
31
+ "displayName": "John Doe",
32
+ "givenName": "John Doe",
33
+ "jobTitle": "Developer",
34
+ "mail": "john@contoso.com",
35
+ "mobilePhone": "0476345130",
36
+ "officeLocation": "Washington",
37
+ "preferredLanguage": "nl-BE",
38
+ "surname": "John",
39
+ "userPrincipalName": "7e06b56615f340138bf879874d52e68ajohn@contoso.com",
40
+ "id": "7e06b566-15f3-4013-8bf8-79874d52e68a"
41
+ }
42
+ ]
43
+ ```
44
+
45
+ === "Text"
46
+
47
+ ```text
48
+ id displayName userPrincipalName
49
+ ------------------------------------ ----------- -----------------------------------------------
50
+ 7e06b566-15f3-4013-8bf8-79874d52e68a John Doe 7e06b56615f340138bf879874d52e68ajohn@contoso.com
51
+ ```
52
+
53
+ === "CSV"
54
+
55
+ ```csv
56
+ id,displayName,userPrincipalName
57
+ 7e06b566-15f3-4013-8bf8-79874d52e68a,John Doe,7e06b56615f340138bf879874d52e68ajohn@contoso.com
58
+ ```
59
+
60
+ === "Markdown"
61
+
62
+ ```md
63
+ # aad user recyclebinitem list
64
+
65
+ Date: 14/02/2023
66
+
67
+ ## John Doe (7e06b566-15f3-4013-8bf8-79874d52e68a)
68
+
69
+ Property | Value
70
+ ---------|-------
71
+ businessPhones | []
72
+ displayName | John Doe
73
+ givenName | John Doe
74
+ jobTitle | Developer
75
+ mail | john@contoso.com
76
+ mobilePhone | 0476345130
77
+ officeLocation | Washington
78
+ preferredLanguage | nl-BE
79
+ surname | John
80
+ userPrincipalName | 7e06b56615f340138bf879874d52e68ajohn@contoso.com
81
+ id | 7e06b566-15f3-4013-8bf8-79874d52e68a
82
+ ```
@@ -21,7 +21,7 @@ m365 aad user recyclebinitem remove [options]
21
21
  ## Remarks
22
22
 
23
23
  !!! important
24
- To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator
24
+ To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator.
25
25
 
26
26
  !!! note
27
27
  After running this command, it may take a minute before the deleted user is effectively removed from the tenant.
@@ -0,0 +1,51 @@
1
+ # aad user remove
2
+
3
+ Removes a specific user
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 aad user remove [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--id [id]`
14
+ : The ID of the user. Specify either `id` or `userName` but not both.
15
+
16
+ `--userName [userName]`
17
+ : User principal name of the user. Specify either `id` or `userName` but not both.
18
+
19
+ `--confirm`
20
+ : Don't prompt for confirmation.
21
+
22
+ --8<-- "docs/cmd/_global.md"
23
+
24
+ ## Remarks
25
+
26
+ !!! important
27
+ If the user with the specified id or user name doesn't exist, you will get a `Resource 'xyz' does not exist or one of its queried reference-property objects are not present.` error.
28
+
29
+ !!! important
30
+ To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator.
31
+
32
+ !!! note
33
+ After running this command, it may take a minute before the user is effectively moved to the recycle bin.
34
+
35
+ ## Examples
36
+
37
+ Removes a specific user by id
38
+
39
+ ```sh
40
+ m365 aad user remove --id a33bd401-9117-4e0e-bb7b-3f61c1539e10
41
+ ```
42
+
43
+ Removes a specific user by its UPN
44
+
45
+ ```sh
46
+ m365 aad user remove --name john.doe@contoso.com
47
+ ```
48
+
49
+ ## Response
50
+
51
+ The command won't return a response on success.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.3.0-beta.82f99fc",
3
+ "version": "6.3.0-beta.98b4bc2",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",