@pnp/cli-microsoft365 4.1.0-beta.4198b60 → 4.1.0-beta.6c0929c
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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const Utils_1 = require("../../../../Utils");
|
|
5
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class AadUserSetCommand extends GraphCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.USER_SET;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Updates information about the specified user';
|
|
13
|
+
}
|
|
14
|
+
allowUnknownOptions() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
getTelemetryProperties(args) {
|
|
18
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
19
|
+
telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
|
|
20
|
+
telemetryProps.userPrincipalName = typeof args.options.userPrincipalName !== 'undefined';
|
|
21
|
+
telemetryProps.accountEnabled = (!!args.options.accountEnabled).toString();
|
|
22
|
+
return telemetryProps;
|
|
23
|
+
}
|
|
24
|
+
commandAction(logger, args, cb) {
|
|
25
|
+
const manifest = this.mapRequestBody(args.options);
|
|
26
|
+
const requestOptions = {
|
|
27
|
+
url: `${this.resource}/v1.0/users/${encodeURIComponent(args.options.objectId ? args.options.objectId : args.options.userPrincipalName)}`,
|
|
28
|
+
headers: {
|
|
29
|
+
accept: 'application/json'
|
|
30
|
+
},
|
|
31
|
+
responseType: 'json',
|
|
32
|
+
data: manifest
|
|
33
|
+
};
|
|
34
|
+
request_1.default
|
|
35
|
+
.patch(requestOptions)
|
|
36
|
+
.then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
37
|
+
}
|
|
38
|
+
mapRequestBody(options) {
|
|
39
|
+
const requestBody = {};
|
|
40
|
+
const excludeOptions = [
|
|
41
|
+
'debug',
|
|
42
|
+
'verbose',
|
|
43
|
+
'output',
|
|
44
|
+
'objectId',
|
|
45
|
+
'i',
|
|
46
|
+
'userPrincipalName',
|
|
47
|
+
'n',
|
|
48
|
+
'accountEnabled'
|
|
49
|
+
];
|
|
50
|
+
if (options.accountEnabled) {
|
|
51
|
+
requestBody['AccountEnabled'] = String(options.accountEnabled) === "true";
|
|
52
|
+
}
|
|
53
|
+
Object.keys(options).forEach(key => {
|
|
54
|
+
if (excludeOptions.indexOf(key) === -1) {
|
|
55
|
+
requestBody[key] = `${options[key]}`;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return requestBody;
|
|
59
|
+
}
|
|
60
|
+
options() {
|
|
61
|
+
const options = [
|
|
62
|
+
{
|
|
63
|
+
option: '-i, --objectId [objectId]'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
option: '-n, --userPrincipalName [userPrincipalName]'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
option: '--accountEnabled [accountEnabled]'
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const parentOptions = super.options();
|
|
73
|
+
return options.concat(parentOptions);
|
|
74
|
+
}
|
|
75
|
+
validate(args) {
|
|
76
|
+
if (!args.options.objectId && !args.options.userPrincipalName) {
|
|
77
|
+
return 'Specify either objectId or userPrincipalName';
|
|
78
|
+
}
|
|
79
|
+
if (args.options.objectId && args.options.userPrincipalName) {
|
|
80
|
+
return 'Specify either objectId or userPrincipalName but not both';
|
|
81
|
+
}
|
|
82
|
+
if (args.options.objectId &&
|
|
83
|
+
!Utils_1.default.isValidGuid(args.options.objectId)) {
|
|
84
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
module.exports = new AadUserSetCommand();
|
|
90
|
+
//# sourceMappingURL=user-set.js.map
|
|
@@ -47,6 +47,7 @@ exports.default = {
|
|
|
47
47
|
SITECLASSIFICATION_SET: `${prefix} siteclassification set`,
|
|
48
48
|
SP_GET: `${prefix} sp get`,
|
|
49
49
|
USER_GET: `${prefix} user get`,
|
|
50
|
-
USER_LIST: `${prefix} user list
|
|
50
|
+
USER_LIST: `${prefix} user list`,
|
|
51
|
+
USER_SET: `${prefix} user set`
|
|
51
52
|
};
|
|
52
53
|
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# aad user set
|
|
2
|
+
|
|
3
|
+
Updates information of the specified user
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
m365 aad user set [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
`-i, --objectId [objectId]`
|
|
14
|
+
: The object ID of the user to update. Specify `objectId` or `userPrincipalName` but not both
|
|
15
|
+
|
|
16
|
+
`-n, --userPrincipalName [userPrincipalName]`
|
|
17
|
+
: User principal name of the user to update. Specify `objectId` or `userPrincipalName` but not both
|
|
18
|
+
|
|
19
|
+
`--accountEnabled [accountEnabled]`
|
|
20
|
+
: Boolean value specifying whether the account is enabled. Valid values are `true,false`
|
|
21
|
+
|
|
22
|
+
--8<-- "docs/cmd/_global.md"
|
|
23
|
+
|
|
24
|
+
## Remarks
|
|
25
|
+
|
|
26
|
+
You can update information of a user, either by specifying that user's id (`objectId`) or user name (`userPrincipalName`), but not both.
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
Update specific property _department_ of user with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
m365 aad user set --objectId 1caf7dcd-7e83-4c3a-94f7-932a1299c844 --Department IT
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Update multiple properties of user with name _steve@contoso.onmicrosoft.com_
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
m365 aad user set --userPrincipalName steve@contoso.onmicrosoft.com --Department "Sales & Marketing" --CompanyName Contoso
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Enable user with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
m365 aad user set --objectId 1caf7dcd-7e83-4c3a-94f7-932a1299c844 --accountEnabled true
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Disable user with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
m365 aad user set --objectId 1caf7dcd-7e83-4c3a-94f7-932a1299c844 --accountEnabled false
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Enable user with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
m365 aad user set --objectId 1caf7dcd-7e83-4c3a-94f7-932a1299c844 --accountEnabled true
|
|
60
|
+
```
|
package/package.json
CHANGED