@pnp/cli-microsoft365 6.0.0-beta.38c66cf → 6.0.0-beta.6a854fc

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.
@@ -9,9 +9,6 @@ class AadAppRemoveCommand extends GraphCommand_1.default {
9
9
  get name() {
10
10
  return commands_1.default.APP_REMOVE;
11
11
  }
12
- alias() {
13
- return [commands_1.default.APP_DELETE];
14
- }
15
12
  get description() {
16
13
  return 'Removes an Azure AD app registration';
17
14
  }
@@ -24,7 +21,6 @@ class AadAppRemoveCommand extends GraphCommand_1.default {
24
21
  return telemetryProps;
25
22
  }
26
23
  commandAction(logger, args, cb) {
27
- this.showDeprecationWarning(logger, commands_1.default.APP_DELETE, commands_1.default.APP_REMOVE);
28
24
  const deleteApp = () => {
29
25
  this
30
26
  .getObjectId(args, logger)
@@ -12,9 +12,6 @@ class AadAppRoleRemoveCommand extends GraphCommand_1.default {
12
12
  get description() {
13
13
  return 'Removes role from the specified Azure AD app registration';
14
14
  }
15
- alias() {
16
- return [commands_1.default.APP_ROLE_DELETE];
17
- }
18
15
  getTelemetryProperties(args) {
19
16
  const telemetryProps = super.getTelemetryProperties(args);
20
17
  telemetryProps.appId = typeof args.options.appId !== 'undefined';
@@ -26,7 +23,6 @@ class AadAppRoleRemoveCommand extends GraphCommand_1.default {
26
23
  return telemetryProps;
27
24
  }
28
25
  commandAction(logger, args, cb) {
29
- this.showDeprecationWarning(logger, commands_1.default.APP_ROLE_DELETE, commands_1.default.APP_ROLE_REMOVE);
30
26
  const deleteAppRole = () => {
31
27
  this
32
28
  .processAppRoleDelete(logger, args)
@@ -14,33 +14,84 @@ class AadO365GroupRecycleBinItemRestoreCommand extends GraphCommand_1.default {
14
14
  alias() {
15
15
  return [commands_1.default.O365GROUP_RESTORE];
16
16
  }
17
+ getTelemetryProperties(args) {
18
+ const telemetryProps = super.getTelemetryProperties(args);
19
+ telemetryProps.id = typeof args.options.id !== 'undefined';
20
+ telemetryProps.displayName = typeof args.options.displayName !== 'undefined';
21
+ telemetryProps.mailNickname = typeof args.options.mailNickname !== 'undefined';
22
+ return telemetryProps;
23
+ }
17
24
  commandAction(logger, args, cb) {
18
25
  if (this.verbose) {
19
- logger.logToStderr(`Restoring Microsoft 365 Group: ${args.options.id}...`);
26
+ logger.logToStderr(`Restoring Microsoft 365 Group: ${args.options.id || args.options.displayName || args.options.mailNickname}...`);
27
+ }
28
+ this
29
+ .getGroupId(args.options)
30
+ .then((groupId) => {
31
+ const requestOptions = {
32
+ url: `${this.resource}/v1.0/directory/deleteditems/${groupId}/restore`,
33
+ headers: {
34
+ accept: 'application/json;odata.metadata=none',
35
+ 'content-type': 'application/json'
36
+ },
37
+ responseType: 'json'
38
+ };
39
+ return request_1.default.post(requestOptions);
40
+ })
41
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
42
+ }
43
+ getGroupId(options) {
44
+ const { id, displayName, mailNickname } = options;
45
+ if (id) {
46
+ return Promise.resolve(id);
47
+ }
48
+ let filterValue = '';
49
+ if (displayName) {
50
+ filterValue = `displayName eq '${utils_1.formatting.encodeQueryParameter(displayName)}'`;
51
+ }
52
+ if (mailNickname) {
53
+ filterValue = `mailNickname eq '${utils_1.formatting.encodeQueryParameter(mailNickname)}'`;
20
54
  }
21
55
  const requestOptions = {
22
- url: `${this.resource}/v1.0/directory/deleteditems/${args.options.id}/restore/`,
56
+ url: `${this.resource}/v1.0/directory/deletedItems/Microsoft.Graph.Group?$filter=${filterValue}`,
23
57
  headers: {
24
- 'accept': 'application/json;odata.metadata=none',
25
- 'content-type': 'application/json'
58
+ accept: 'application/json;odata.metadata=none'
26
59
  },
27
60
  responseType: 'json'
28
61
  };
29
- request_1.default
30
- .post(requestOptions)
31
- .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
62
+ return request_1.default
63
+ .get(requestOptions)
64
+ .then((response) => {
65
+ const groups = response.value;
66
+ if (groups.length === 0) {
67
+ return Promise.reject(`The specified group '${displayName || mailNickname}' does not exist.`);
68
+ }
69
+ if (groups.length > 1) {
70
+ return Promise.reject(`Multiple groups with name '${displayName || mailNickname}' found: ${groups.map(x => x.id).join(',')}.`);
71
+ }
72
+ return Promise.resolve(groups[0].id);
73
+ });
74
+ }
75
+ optionSets() {
76
+ return [['id', 'displayName', 'mailNickname']];
32
77
  }
33
78
  options() {
34
79
  const options = [
35
80
  {
36
- option: '-i, --id <id>'
81
+ option: '-i, --id [id]'
82
+ },
83
+ {
84
+ option: '-d, --displayName [displayName]'
85
+ },
86
+ {
87
+ option: '-m, --mailNickname [mailNickname]'
37
88
  }
38
89
  ];
39
90
  const parentOptions = super.options();
40
91
  return options.concat(parentOptions);
41
92
  }
42
93
  validate(args) {
43
- if (!utils_1.validation.isValidGuid(args.options.id)) {
94
+ if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
44
95
  return `${args.options.id} is not a valid GUID`;
45
96
  }
46
97
  return true;
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'aad';
4
4
  exports.default = {
5
5
  APP_ADD: `${prefix} app add`,
6
- APP_DELETE: `${prefix} app delete`,
7
6
  APP_GET: `${prefix} app get`,
8
7
  APP_REMOVE: `${prefix} app remove`,
9
8
  APP_ROLE_ADD: `${prefix} app role add`,
10
- APP_ROLE_DELETE: `${prefix} app role delete`,
11
9
  APP_ROLE_LIST: `${prefix} app role list`,
12
10
  APP_ROLE_REMOVE: `${prefix} app role remove`,
13
11
  APP_SET: `${prefix} app set`,
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../../../utils");
4
+ const request_1 = require("../../../../request");
5
+ const SpoCommand_1 = require("../../../base/SpoCommand");
6
+ const commands_1 = require("../../commands");
7
+ class SpoGroupAddCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.GROUP_ADD;
10
+ }
11
+ get description() {
12
+ return 'Creates group in the specified site';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.description = typeof args.options.description !== 'undefined';
17
+ telemetryProps.allowMembersEditMembership = typeof args.options.allowMembersEditMembership !== 'undefined';
18
+ telemetryProps.onlyAllowMembersViewMembership = typeof args.options.onlyAllowMembersViewMembership !== 'undefined';
19
+ telemetryProps.allowRequestToJoinLeave = typeof args.options.allowRequestToJoinLeave !== 'undefined';
20
+ telemetryProps.autoAcceptRequestToJoinLeave = typeof args.options.autoAcceptRequestToJoinLeave !== 'undefined';
21
+ telemetryProps.requestToJoinLeaveEmailSetting = typeof args.options.requestToJoinLeaveEmailSetting !== 'undefined';
22
+ return telemetryProps;
23
+ }
24
+ commandAction(logger, args, cb) {
25
+ const requestOptions = {
26
+ url: `${args.options.webUrl}/_api/web/sitegroups`,
27
+ headers: {
28
+ accept: 'application/json;odata=nometadata'
29
+ },
30
+ responseType: 'json',
31
+ data: {
32
+ Title: args.options.name,
33
+ Description: args.options.description,
34
+ AllowMembersEditMembership: args.options.allowMembersEditMembership,
35
+ OnlyAllowMembersViewMembership: args.options.onlyAllowMembersViewMembership,
36
+ AllowRequestToJoinLeave: args.options.allowRequestToJoinLeave,
37
+ AutoAcceptRequestToJoinLeave: args.options.autoAcceptRequestToJoinLeave,
38
+ RequestToJoinLeaveEmailSetting: args.options.requestToJoinLeaveEmailSetting
39
+ }
40
+ };
41
+ request_1.default
42
+ .post(requestOptions)
43
+ .then((response) => {
44
+ logger.log(response);
45
+ cb();
46
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
47
+ }
48
+ options() {
49
+ const options = [
50
+ {
51
+ option: '-u, --webUrl <webUrl>'
52
+ },
53
+ {
54
+ option: '-n, --name <name>'
55
+ },
56
+ {
57
+ option: '--description [description]'
58
+ },
59
+ {
60
+ option: '--allowMembersEditMembership [allowMembersEditMembership]'
61
+ },
62
+ {
63
+ option: '--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]'
64
+ },
65
+ {
66
+ option: '--allowRequestToJoinLeave [allowRequestToJoinLeave]'
67
+ },
68
+ {
69
+ option: '--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]'
70
+ },
71
+ {
72
+ option: '--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]'
73
+ }
74
+ ];
75
+ const parentOptions = super.options();
76
+ return options.concat(parentOptions);
77
+ }
78
+ validate(args) {
79
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
80
+ if (isValidSharePointUrl !== true) {
81
+ return isValidSharePointUrl;
82
+ }
83
+ const booleanOptions = [
84
+ args.options.allowMembersEditMembership, args.options.onlyAllowMembersViewMembership,
85
+ args.options.allowRequestToJoinLeave, args.options.autoAcceptRequestToJoinLeave
86
+ ];
87
+ for (const option of booleanOptions) {
88
+ if (typeof option !== 'undefined' && !utils_1.validation.isValidBoolean(option)) {
89
+ return `Value '${option}' is not a valid boolean`;
90
+ }
91
+ }
92
+ return true;
93
+ }
94
+ }
95
+ module.exports = new SpoGroupAddCommand();
96
+ //# sourceMappingURL=group-add.js.map
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
3
4
  const request_1 = require("../../../../request");
4
5
  const utils_1 = require("../../../../utils");
5
6
  const SpoCommand_1 = require("../../../base/SpoCommand");
6
7
  const commands_1 = require("../../commands");
8
+ const SpoListItemListCommand = require("../listitem/listitem-list");
7
9
  class SpoHubSiteGetCommand extends SpoCommand_1.default {
8
10
  get name() {
9
11
  return commands_1.default.HUBSITE_GET;
@@ -16,9 +18,24 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
16
18
  telemetryProps.id = typeof args.options.id !== 'undefined';
17
19
  telemetryProps.title = typeof args.options.title !== 'undefined';
18
20
  telemetryProps.url = typeof args.options.url !== 'undefined';
21
+ telemetryProps.includeAssociatedSites = args.options.includeAssociatedSites === true;
19
22
  return telemetryProps;
20
23
  }
24
+ getAssociatedSites(spoAdminUrl, hubSiteId, logger, args) {
25
+ const options = {
26
+ output: 'json',
27
+ debug: args.options.debug,
28
+ verbose: args.options.verbose,
29
+ listTitle: 'DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS',
30
+ webUrl: spoAdminUrl,
31
+ filter: `HubSiteId eq '${hubSiteId}'`,
32
+ fields: 'Title,SiteUrl,SiteId'
33
+ };
34
+ return cli_1.Cli
35
+ .executeCommandWithOutput(SpoListItemListCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
36
+ }
21
37
  commandAction(logger, args, cb) {
38
+ let hubSite;
22
39
  utils_1.spo
23
40
  .getSpoUrl(logger, this.debug)
24
41
  .then((spoUrl) => {
@@ -30,7 +47,25 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
30
47
  }
31
48
  })
32
49
  .then((res) => {
33
- logger.log(res);
50
+ hubSite = res;
51
+ if (args.options.includeAssociatedSites && (args.options.output && args.options.output !== 'json')) {
52
+ throw Error('includeAssociatedSites option is only allowed with json output mode');
53
+ }
54
+ if (args.options.includeAssociatedSites !== true || args.options.output && args.options.output !== 'json') {
55
+ return Promise.resolve();
56
+ }
57
+ return utils_1.spo
58
+ .getSpoAdminUrl(logger, this.debug)
59
+ .then((spoAdminUrl) => {
60
+ return this.getAssociatedSites(spoAdminUrl, hubSite.SiteId, logger, args);
61
+ });
62
+ })
63
+ .then((associatedSitesCommandOutput) => {
64
+ if (args.options.includeAssociatedSites) {
65
+ const associatedSites = JSON.parse(associatedSitesCommandOutput.stdout);
66
+ hubSite.AssociatedSites = associatedSites.filter(s => s.SiteId !== hubSite.SiteId);
67
+ }
68
+ logger.log(hubSite);
34
69
  cb();
35
70
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
36
71
  }
@@ -75,7 +110,8 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
75
110
  const options = [
76
111
  { option: '-i, --id [id]' },
77
112
  { option: '-t, --title [title]' },
78
- { option: '-u, --url [url]' }
113
+ { option: '-u, --url [url]' },
114
+ { option: '--includeAssociatedSites' }
79
115
  ];
80
116
  const parentOptions = super.options();
81
117
  return options.concat(parentOptions);
@@ -13,10 +13,8 @@ class SpoListItemListCommand extends SpoCommand_1.default {
13
13
  }
14
14
  getTelemetryProperties(args) {
15
15
  const telemetryProps = super.getTelemetryProperties(args);
16
- telemetryProps.id = typeof args.options.id !== 'undefined';
17
16
  telemetryProps.listId = typeof args.options.listId !== 'undefined';
18
17
  telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
19
- telemetryProps.title = typeof args.options.title !== 'undefined';
20
18
  telemetryProps.fields = typeof args.options.fields !== 'undefined';
21
19
  telemetryProps.filter = typeof args.options.filter !== 'undefined';
22
20
  telemetryProps.pageNumber = typeof args.options.pageNumber !== 'undefined';
@@ -25,14 +23,8 @@ class SpoListItemListCommand extends SpoCommand_1.default {
25
23
  return telemetryProps;
26
24
  }
27
25
  commandAction(logger, args, cb) {
28
- if (args.options.id) {
29
- this.warn(logger, `Option 'id' is deprecated. Please use 'listId' instead.`);
30
- }
31
- if (args.options.title) {
32
- this.warn(logger, `Option 'title' is deprecated. Please use 'listTitle' instead.`);
33
- }
34
- const listIdArgument = args.options.listId || args.options.id || '';
35
- const listTitleArgument = args.options.listTitle || args.options.title || '';
26
+ const listIdArgument = args.options.listId || '';
27
+ const listTitleArgument = args.options.listTitle || '';
36
28
  let formDigestValue = '';
37
29
  const fieldsArray = args.options.fields ? args.options.fields.split(",")
38
30
  : (!args.options.output || args.options.output === "text") ? ["Title", "Id"] : [];
@@ -111,12 +103,6 @@ class SpoListItemListCommand extends SpoCommand_1.default {
111
103
  {
112
104
  option: '-u, --webUrl <webUrl>'
113
105
  },
114
- {
115
- option: '--id [id]'
116
- },
117
- {
118
- option: '--title [title]'
119
- },
120
106
  {
121
107
  option: '-i, --listId [listId]'
122
108
  },
@@ -161,14 +147,10 @@ class SpoListItemListCommand extends SpoCommand_1.default {
161
147
  if (isValidSharePointUrl !== true) {
162
148
  return isValidSharePointUrl;
163
149
  }
164
- if (!args.options.id && !args.options.title && !args.options.listId && !args.options.listTitle) {
150
+ if (!args.options.listId && !args.options.listTitle) {
165
151
  return `Specify listId or listTitle`;
166
152
  }
167
- if (args.options.id && args.options.title) {
168
- return `Specify list id or title but not both`;
169
- }
170
- // Check if only one of the 4 options is specified
171
- if ([args.options.id, args.options.title, args.options.listId, args.options.listTitle].filter(o => o).length > 1) {
153
+ if (args.options.listId && args.options.listTitle) {
172
154
  return 'Specify listId or listTitle but not both';
173
155
  }
174
156
  if (args.options.camlQuery && args.options.fields) {
@@ -192,9 +174,6 @@ class SpoListItemListCommand extends SpoCommand_1.default {
192
174
  if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
193
175
  return `${args.options.listId} is not a valid GUID`;
194
176
  }
195
- if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
196
- return `${args.options.id} in option id is not a valid GUID`;
197
- }
198
177
  return true;
199
178
  }
200
179
  }
@@ -23,6 +23,7 @@ class SpoSiteClassicListCommand extends SpoCommand_1.default {
23
23
  return ['Title', 'Url'];
24
24
  }
25
25
  commandAction(logger, args, cb) {
26
+ this.showDeprecationWarning(logger, commands_1.default.SITE_CLASSIC_LIST, commands_1.default.SITE_LIST);
26
27
  const webTemplate = args.options.webTemplate || '';
27
28
  const includeOneDriveSites = args.options.includeOneDriveSites || false;
28
29
  const personalSite = includeOneDriveSites === false ? '0' : '1';
@@ -10,22 +10,25 @@ class SpoSiteListCommand extends SpoCommand_1.default {
10
10
  return commands_1.default.SITE_LIST;
11
11
  }
12
12
  get description() {
13
- return 'Lists modern sites of the given type';
13
+ return 'Lists sites of the given type';
14
14
  }
15
15
  getTelemetryProperties(args) {
16
16
  const telemetryProps = super.getTelemetryProperties(args);
17
- telemetryProps.siteType = args.options.type || 'TeamSite';
17
+ telemetryProps.webTemplate = args.options.webTemplate;
18
18
  telemetryProps.filter = (!(!args.options.filter)).toString();
19
- telemetryProps.deleted = args.options.deleted;
19
+ telemetryProps.includeOneDriveSites = typeof args.options.includeOneDriveSites !== 'undefined';
20
+ telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
21
+ telemetryProps.siteType = args.options.type || 'TeamSite';
20
22
  return telemetryProps;
21
23
  }
22
24
  defaultProperties() {
23
25
  return ['Title', 'Url'];
24
26
  }
25
27
  commandAction(logger, args, cb) {
26
- const siteType = args.options.type || 'TeamSite';
27
- const webTemplate = siteType === 'TeamSite' ? 'GROUP#0' : 'SITEPAGEPUBLISHING#0';
28
- let spoAdminUrl;
28
+ const webTemplate = this.getWebTemplateId(args.options);
29
+ const includeOneDriveSites = args.options.includeOneDriveSites || false;
30
+ const personalSite = includeOneDriveSites === false ? '0' : '1';
31
+ let spoAdminUrl = '';
29
32
  utils_1.spo
30
33
  .getSpoAdminUrl(logger, this.debug)
31
34
  .then((_spoAdminUrl) => {
@@ -34,19 +37,19 @@ class SpoSiteListCommand extends SpoCommand_1.default {
34
37
  logger.logToStderr(`Retrieving list of site collections...`);
35
38
  }
36
39
  this.allSites = [];
37
- return this.getAllSites(spoAdminUrl, utils_1.formatting.escapeXml(args.options.filter || ''), '0', webTemplate, undefined, args.options.deleted, logger);
40
+ return this.getAllSites(spoAdminUrl, utils_1.formatting.escapeXml(args.options.filter || ''), '0', personalSite, webTemplate, undefined, args.options.deleted, logger);
38
41
  })
39
42
  .then(_ => {
40
43
  logger.log(this.allSites);
41
44
  cb();
42
45
  }, (err) => this.handleRejectedPromise(err, logger, cb));
43
46
  }
44
- getAllSites(spoAdminUrl, filter, startIndex, webTemplate, formDigest, deleted, logger) {
47
+ getAllSites(spoAdminUrl, filter, startIndex, personalSite, webTemplate, formDigest, deleted, logger) {
45
48
  return new Promise((resolve, reject) => {
46
49
  utils_1.spo
47
50
  .ensureFormDigest(spoAdminUrl, logger, formDigest, this.debug)
48
51
  .then((res) => {
49
- let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="Filter" Type="String">${filter}</Property><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">0</Property><Property Name="StartIndex" Type="String">${startIndex}</Property><Property Name="Template" Type="String">${webTemplate}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`;
52
+ let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="Filter" Type="String">${filter}</Property><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">${personalSite}</Property><Property Name="StartIndex" Type="String">${startIndex}</Property><Property Name="Template" Type="String">${webTemplate}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`;
50
53
  if (deleted) {
51
54
  requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="5"><Query SelectAllProperties="true"><Properties><Property Name="NextStartIndexFromSharePoint" ScalarProperty="true" /></Properties></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="5" ParentId="3" Name="GetDeletedSitePropertiesFromSharePoint"><Parameters><Parameter Type="String">${startIndex}</Parameter></Parameters></Method></ObjectPaths></Request>`;
52
55
  }
@@ -71,7 +74,7 @@ class SpoSiteListCommand extends SpoCommand_1.default {
71
74
  this.allSites.push(...sites._Child_Items_);
72
75
  if (sites.NextStartIndexFromSharePoint) {
73
76
  this
74
- .getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, webTemplate, formDigest, deleted, logger)
77
+ .getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, personalSite, webTemplate, formDigest, deleted, logger)
75
78
  .then(_ => resolve(), err => reject(err));
76
79
  }
77
80
  else {
@@ -81,15 +84,48 @@ class SpoSiteListCommand extends SpoCommand_1.default {
81
84
  }, err => reject(err));
82
85
  });
83
86
  }
87
+ /*
88
+ The type property currently defaults to Teamsite.
89
+ It makes more sense to default to All. Certainly after adding the 'includeOneDriveSites' option.
90
+ Changing this will be a breaking change. We'll remove the default the next major version.
91
+ */
92
+ getWebTemplateId(options) {
93
+ if (options.webTemplate) {
94
+ return options.webTemplate;
95
+ }
96
+ if (options.includeOneDriveSites) {
97
+ return '';
98
+ }
99
+ let siteType = options.type;
100
+ if (!siteType) {
101
+ siteType = 'TeamSite';
102
+ }
103
+ switch (siteType) {
104
+ case "TeamSite":
105
+ return 'GROUP#0';
106
+ case "CommunicationSite":
107
+ return 'SITEPAGEPUBLISHING#0';
108
+ default:
109
+ return '';
110
+ }
111
+ }
84
112
  options() {
85
113
  const options = [
86
114
  {
87
- option: '--type [type]',
88
- autocomplete: ['TeamSite', 'CommunicationSite']
115
+ option: '-t, --type [type]',
116
+ // To not introduce a breaking change, 'All' has been added.
117
+ // You should use all when using '--includeOneDriveSites'
118
+ autocomplete: ['TeamSite', 'CommunicationSite', 'All']
119
+ },
120
+ {
121
+ option: '--webTemplate [webTemplate]'
89
122
  },
90
123
  {
91
124
  option: '-f, --filter [filter]'
92
125
  },
126
+ {
127
+ option: '--includeOneDriveSites'
128
+ },
93
129
  {
94
130
  option: '--deleted'
95
131
  }
@@ -98,11 +134,17 @@ class SpoSiteListCommand extends SpoCommand_1.default {
98
134
  return options.concat(parentOptions);
99
135
  }
100
136
  validate(args) {
101
- if (args.options.type) {
102
- if (args.options.type !== 'TeamSite' &&
103
- args.options.type !== 'CommunicationSite') {
104
- return `${args.options.type} is not a valid modern site type. Allowed types are TeamSite and CommunicationSite`;
105
- }
137
+ if (args.options.type && args.options.webTemplate) {
138
+ return 'Specify either type or webTemplate, but not both';
139
+ }
140
+ const typeValues = ['TeamSite', 'CommunicationSite', 'All'];
141
+ if (args.options.type &&
142
+ typeValues.indexOf(args.options.type) < 0) {
143
+ return `${args.options.type} is not a valid value for the type option. Allowed values are ${typeValues.join('|')}`;
144
+ }
145
+ if (args.options.includeOneDriveSites
146
+ && (!args.options.type || args.options.type !== 'All')) {
147
+ return 'When using includeOneDriveSites, specify All as value for type';
106
148
  }
107
149
  return true;
108
150
  }
@@ -63,6 +63,7 @@ exports.default = {
63
63
  FOLDER_REMOVE: `${prefix} folder remove`,
64
64
  FOLDER_RENAME: `${prefix} folder rename`,
65
65
  GET: `${prefix} get`,
66
+ GROUP_ADD: `${prefix} group add`,
66
67
  GROUP_GET: `${prefix} group get`,
67
68
  GROUP_LIST: `${prefix} group list`,
68
69
  GROUP_REMOVE: `${prefix} group remove`,
@@ -8,12 +8,6 @@ Removes an Azure AD app registration
8
8
  m365 aad app remove [options]
9
9
  ```
10
10
 
11
- ## Alias
12
-
13
- ```sh
14
- m365 aad app delete [options]
15
- ```
16
-
17
11
  ## Options
18
12
 
19
13
  `--appId [appId]`
@@ -8,12 +8,6 @@ Removes role from the specified Azure AD app registration
8
8
  m365 aad app role remove [options]
9
9
  ```
10
10
 
11
- ## Alias
12
-
13
- ```sh
14
- m365 aad app role delete [options]
15
- ```
16
-
17
11
  ## Options
18
12
 
19
13
  `--appId [appId]`
@@ -16,15 +16,33 @@ m365 aad o365group restore [options]
16
16
 
17
17
  ## Options
18
18
 
19
- `-i, --id <id>`
20
- : The ID of the Microsoft 365 Group to restore
19
+ `-i, --id [id]`
20
+ : The ID of the Microsoft 365 Group to restore. Specify either `id`, `displayName` or `mailNickname` but not multiple.
21
+
22
+ `-d, --displayName [displayName]`
23
+ : Display name for the Microsoft 365 Group to restore. Specify either `id`, `displayName` or `mailNickname` but not multiple.
24
+
25
+ `-m, --mailNickname [mailNickname]`
26
+ : Name of the group e-mail (part before the @). Specify either `id`, `displayName` or `mailNickname` but not multiple.
21
27
 
22
28
  --8<-- "docs/cmd/_global.md"
23
29
 
24
30
  ## Examples
25
31
 
26
- Restores the Microsoft 365 Group with id _28beab62-7540-4db1-a23f-29a6018a3848_
32
+ Restores the Microsoft 365 Group with specific ID
27
33
 
28
34
  ```sh
29
35
  m365 aad o365group recyclebinitem restore --id 28beab62-7540-4db1-a23f-29a6018a3848
30
36
  ```
37
+
38
+ Restores the Microsoft 365 Group with specific name
39
+
40
+ ```sh
41
+ m365 aad o365group recyclebinitem restore --displayName "My Group"
42
+ ```
43
+
44
+ Restores the Microsoft 365 Group with specific mail nickname
45
+
46
+ ```sh
47
+ m365 aad o365group recyclebinitem restore --mailNickname "Mygroup"
48
+ ```
@@ -0,0 +1,51 @@
1
+ # spo group add
2
+
3
+ Creates group in the specified site
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo group add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site where the group should be added.
15
+
16
+ `-n, --name <name>`
17
+ : Name of the group to add.
18
+
19
+ `--description [description]`
20
+ : The description for the group.
21
+
22
+ `--allowMembersEditMembership [allowMembersEditMembership]`
23
+ : Who can edit the membership of the group? When `true` members can edit membership, otherwise only owners can do this. Default `false`.
24
+
25
+ `--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]`
26
+ : Who can view the membership of the group? When `false` everyone can view the group membership, otherwise only group members can. Default `true`.
27
+
28
+ `--allowRequestToJoinLeave [allowRequestToJoinLeave]`
29
+ : Specify whether to allow users to request membership in this group and allow users to request to leave the group. Default `false`.
30
+
31
+ `--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]`
32
+ : If auto-accept is enabled, users will automatically be added or removed when they make a request. Default `false`.
33
+
34
+ `--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]`
35
+ : All membership requests will be sent to the email address specified.
36
+
37
+ --8<-- "docs/cmd/_global.md"
38
+
39
+ ## Examples
40
+
41
+ Create group with title and description
42
+
43
+ ```sh
44
+ m365 spo group add --webUrl https://contoso.sharepoint.com/sites/project-x --name "Project leaders" --description "This group contains all project leaders"
45
+ ```
46
+
47
+ Create group with membership requests
48
+
49
+ ```sh
50
+ m365 spo group add --webUrl https://contoso.sharepoint.com/sites/project-x --name "Project leaders" --allowRequestToJoinLeave true --requestToJoinLeaveEmailSetting john.doe@contoso.com
51
+ ```