@pnp/cli-microsoft365 5.0.0-beta.a6d30c1 → 5.0.0-beta.c75d5fc
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,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class SpoGroupUserRemoveCommand extends SpoCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.GROUP_USER_REMOVE;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Removes the specified user from a SharePoint group';
|
|
13
|
+
}
|
|
14
|
+
getTelemetryProperties(args) {
|
|
15
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
|
+
telemetryProps.groupId = (!(!args.options.groupId)).toString();
|
|
17
|
+
telemetryProps.groupName = (!(!args.options.groupName)).toString();
|
|
18
|
+
telemetryProps.confirm = (!(!args.options.confirm)).toString();
|
|
19
|
+
return telemetryProps;
|
|
20
|
+
}
|
|
21
|
+
commandAction(logger, args, cb) {
|
|
22
|
+
const removeUserfromSPGroup = () => {
|
|
23
|
+
if (this.verbose) {
|
|
24
|
+
logger.logToStderr(`Removing User with Username ${args.options.userName} from Group: ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
|
|
25
|
+
}
|
|
26
|
+
const loginName = `i:0#.f|membership|${args.options.userName}`;
|
|
27
|
+
const requestUrl = `${args.options.webUrl}/_api/web/sitegroups/${args.options.groupId
|
|
28
|
+
? `GetById('${encodeURIComponent(args.options.groupId)}')`
|
|
29
|
+
: `GetByName('${encodeURIComponent(args.options.groupName)}')`}/users/removeByLoginName(@LoginName)?@LoginName='${encodeURIComponent(loginName)}'`;
|
|
30
|
+
const requestOptions = {
|
|
31
|
+
url: requestUrl,
|
|
32
|
+
headers: {
|
|
33
|
+
'accept': 'application/json;odata=nometadata'
|
|
34
|
+
},
|
|
35
|
+
responseType: 'json'
|
|
36
|
+
};
|
|
37
|
+
request_1.default
|
|
38
|
+
.post(requestOptions)
|
|
39
|
+
.then(() => {
|
|
40
|
+
cb();
|
|
41
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
42
|
+
};
|
|
43
|
+
if (args.options.confirm) {
|
|
44
|
+
if (this.debug) {
|
|
45
|
+
logger.logToStderr('Confirmation bypassed by entering confirm option. Removing the user from SharePoint Group...');
|
|
46
|
+
}
|
|
47
|
+
removeUserfromSPGroup();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
cli_1.Cli.prompt({
|
|
51
|
+
type: 'confirm',
|
|
52
|
+
name: 'continue',
|
|
53
|
+
default: false,
|
|
54
|
+
message: `Are you sure you want to remove user User ${args.options.userName} from SharePoint group?`
|
|
55
|
+
}, (result) => {
|
|
56
|
+
if (!result.continue) {
|
|
57
|
+
cb();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
removeUserfromSPGroup();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
options() {
|
|
66
|
+
const options = [
|
|
67
|
+
{
|
|
68
|
+
option: '-u, --webUrl <webUrl>'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
option: '--groupId [groupId]'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
option: '--groupName [groupName]'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
option: '--userName <userName>'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
option: '--confirm'
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
const parentOptions = super.options();
|
|
84
|
+
return options.concat(parentOptions);
|
|
85
|
+
}
|
|
86
|
+
validate(args) {
|
|
87
|
+
if (args.options.groupId && args.options.groupName) {
|
|
88
|
+
return 'Use either "groupName" or "groupId", but not both';
|
|
89
|
+
}
|
|
90
|
+
if (!args.options.groupId && !args.options.groupName) {
|
|
91
|
+
return 'Either "groupName" or "groupId" is required';
|
|
92
|
+
}
|
|
93
|
+
if (args.options.groupId && isNaN(args.options.groupId)) {
|
|
94
|
+
return `Specified "groupId" ${args.options.groupId} is not valid`;
|
|
95
|
+
}
|
|
96
|
+
return SpoCommand_1.default.isValidSharePointUrl(args.options.webUrl);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
module.exports = new SpoGroupUserRemoveCommand();
|
|
100
|
+
//# sourceMappingURL=group-user-remove.js.map
|
|
@@ -64,6 +64,7 @@ exports.default = {
|
|
|
64
64
|
GROUP_REMOVE: `${prefix} group remove`,
|
|
65
65
|
GROUP_USER_ADD: `${prefix} group user add`,
|
|
66
66
|
GROUP_USER_LIST: `${prefix} group user list`,
|
|
67
|
+
GROUP_USER_REMOVE: `${prefix} group user remove`,
|
|
67
68
|
HIDEDEFAULTTHEMES_GET: `${prefix} hidedefaultthemes get`,
|
|
68
69
|
HIDEDEFAULTTHEMES_SET: `${prefix} hidedefaultthemes set`,
|
|
69
70
|
HOMESITE_GET: `${prefix} homesite get`,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# spo group user remove
|
|
2
|
+
|
|
3
|
+
Removes the specified user from a SharePoint group
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
m365 spo group user remove [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
`-u, --webUrl <webUrl>`
|
|
14
|
+
: URL of the site where the SharePoint group is available
|
|
15
|
+
|
|
16
|
+
`--groupId [groupId]`
|
|
17
|
+
: Id of the SharePoint group from which user has to be removed from. Use either `groupName` or `groupId`, but not both
|
|
18
|
+
|
|
19
|
+
`--groupName [groupName]`
|
|
20
|
+
: Name of the SharePoint group from which user has to be removed from. Use either `groupName` or `groupId`, but not both
|
|
21
|
+
|
|
22
|
+
`--userName <userName>`
|
|
23
|
+
: User's UPN (user principal name, eg. megan.bowen@contoso.com).
|
|
24
|
+
|
|
25
|
+
--8<-- "docs/cmd/_global.md"
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
Remove a user from SharePoint group with id _5_ available on the web _https://contoso.sharepoint.com/sites/SiteA_
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
m365 spo group user remove --webUrl https://contoso.sharepoint.com/sites/SiteA --groupId 5 --userName "Alex.Wilber@contoso.com"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Remove a user from SharePoint group with Name _Site A Visitors_ available on the web _https://contoso.sharepoint.com/sites/SiteA_
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
m365 spo group user remove --webUrl https://contoso.sharepoint.com/sites/SiteA --groupName "Site A Visitors" --userName "Alex.Wilber@contoso.com"
|
|
39
|
+
```
|
|
@@ -16,7 +16,7 @@ m365 teams channel get [options]
|
|
|
16
16
|
`--teamName [teamName]`
|
|
17
17
|
: The display name of the team to which the channel belongs to. Specify either teamId or teamName but not both
|
|
18
18
|
|
|
19
|
-
`-c, --channelId
|
|
19
|
+
`-c, --channelId [channelId]`
|
|
20
20
|
: The ID of the channel for which to retrieve more information. Specify either channelId or channelName but not both
|
|
21
21
|
|
|
22
22
|
`--channelName [channelName]`
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Command_1 = require("../../Command");
|
|
4
|
-
class AadCommand extends Command_1.default {
|
|
5
|
-
get resource() {
|
|
6
|
-
return 'https://graph.windows.net';
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.default = AadCommand;
|
|
10
|
-
//# sourceMappingURL=AadCommand.js.map
|