@pnp/cli-microsoft365 7.3.0-beta.4df0638 → 7.3.0-beta.66401a3

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.
Files changed (33) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +3 -0
  4. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-add.js +137 -0
  5. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-get.js +112 -0
  6. package/dist/m365/aad/commands/app/app-permission-add.js +237 -0
  7. package/dist/m365/aad/commands.js +4 -1
  8. package/dist/m365/base/PowerAutomateCommand.js +18 -0
  9. package/dist/m365/flow/commands/environment/environment-get.js +3 -3
  10. package/dist/m365/flow/commands/environment/environment-list.js +3 -3
  11. package/dist/m365/flow/commands/flow-disable.js +3 -3
  12. package/dist/m365/flow/commands/flow-enable.js +3 -3
  13. package/dist/m365/flow/commands/flow-get.js +3 -3
  14. package/dist/m365/flow/commands/flow-list.js +14 -12
  15. package/dist/m365/flow/commands/flow-remove.js +3 -3
  16. package/dist/m365/flow/commands/owner/owner-ensure.js +3 -3
  17. package/dist/m365/flow/commands/owner/owner-list.js +3 -3
  18. package/dist/m365/flow/commands/owner/owner-remove.js +3 -3
  19. package/dist/m365/flow/commands/run/run-cancel.js +3 -3
  20. package/dist/m365/flow/commands/run/run-get.js +3 -3
  21. package/dist/m365/flow/commands/run/run-list.js +8 -7
  22. package/dist/m365/flow/commands/run/run-resubmit.js +4 -4
  23. package/dist/m365/teams/commands/app/app-install.js +30 -3
  24. package/dist/m365/teams/commands/user/user-app-add.js +23 -5
  25. package/dist/utils/aadAdministrativeUnit.js +4 -4
  26. package/dist/utils/aadDevice.js +25 -0
  27. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-add.mdx +93 -0
  28. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-get.mdx +130 -0
  29. package/docs/docs/cmd/aad/app/app-permission-add.mdx +62 -0
  30. package/docs/docs/cmd/teams/app/app-install.mdx +11 -2
  31. package/docs/docs/cmd/teams/user/user-app-add.mdx +12 -3
  32. package/docs/docs/cmd/teams/user/user-app-remove.mdx +2 -2
  33. package/package.json +1 -1
@@ -5,9 +5,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _FlowListCommand_instances, _FlowListCommand_initTelemetry, _FlowListCommand_initOptions, _FlowListCommand_initValidators;
7
7
  import { formatting } from '../../../utils/formatting.js';
8
- import { AzmgmtItemsListCommand } from '../../base/AzmgmtItemsListCommand.js';
8
+ import { odata } from '../../../utils/odata.js';
9
+ import PowerAutomateCommand from '../../base/PowerAutomateCommand.js';
9
10
  import commands from '../commands.js';
10
- class FlowListCommand extends AzmgmtItemsListCommand {
11
+ class FlowListCommand extends PowerAutomateCommand {
11
12
  get name() {
12
13
  return commands.LIST;
13
14
  }
@@ -28,31 +29,32 @@ class FlowListCommand extends AzmgmtItemsListCommand {
28
29
  async commandAction(logger, args) {
29
30
  try {
30
31
  const { environmentName, asAdmin, sharingStatus, includeSolutions } = args.options;
32
+ let items = [];
31
33
  if (sharingStatus === 'personal') {
32
34
  const url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'personal');
33
- await this.getAllItems(url, logger, true);
35
+ items = await odata.getAllItems(url);
34
36
  }
35
37
  else if (sharingStatus === 'sharedWithMe') {
36
38
  const url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'team');
37
- await this.getAllItems(url, logger, true);
39
+ items = await odata.getAllItems(url);
38
40
  }
39
41
  else if (sharingStatus === 'all') {
40
42
  let url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'personal');
41
- await this.getAllItems(url, logger, true);
43
+ items = await odata.getAllItems(url);
42
44
  url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'team');
43
- await this.getAllItems(url, logger, false);
45
+ items = await odata.getAllItems(url);
44
46
  }
45
47
  else {
46
48
  const url = this.getApiUrl(environmentName, asAdmin, includeSolutions);
47
- await this.getAllItems(url, logger, true);
49
+ items = await odata.getAllItems(url);
48
50
  }
49
51
  // Remove duplicates
50
- this.items = this.items.filter((flow, index, self) => index === self.findIndex(f => f.id === flow.id));
51
- if (this.items.length > 0) {
52
- this.items.forEach(i => {
52
+ items = items.filter((flow, index, self) => index === self.findIndex(f => f.id === flow.id));
53
+ if (items.length > 0) {
54
+ items.forEach(i => {
53
55
  i.displayName = i.properties.displayName;
54
56
  });
55
- await logger.log(this.items);
57
+ await logger.log(items);
56
58
  }
57
59
  else {
58
60
  if (this.verbose) {
@@ -65,7 +67,7 @@ class FlowListCommand extends AzmgmtItemsListCommand {
65
67
  }
66
68
  }
67
69
  getApiUrl(environmentName, asAdmin, includeSolutionFlows, filter) {
68
- let url = `${this.resource}providers/Microsoft.ProcessSimple${asAdmin ? '/scopes/admin' : ''}/environments/${formatting.encodeQueryParameter(environmentName)}/flows?api-version=2016-11-01`;
70
+ let url = `${this.resource}/providers/Microsoft.ProcessSimple${asAdmin ? '/scopes/admin' : ''}/environments/${formatting.encodeQueryParameter(environmentName)}/flows?api-version=2016-11-01`;
69
71
  if (filter === 'personal') {
70
72
  url += `&$filter=search('personal')`;
71
73
  }
@@ -8,9 +8,9 @@ import { cli } from '../../../cli/cli.js';
8
8
  import request from '../../../request.js';
9
9
  import { formatting } from '../../../utils/formatting.js';
10
10
  import { validation } from '../../../utils/validation.js';
11
- import AzmgmtCommand from '../../base/AzmgmtCommand.js';
12
11
  import commands from '../commands.js';
13
- class FlowRemoveCommand extends AzmgmtCommand {
12
+ import PowerAutomateCommand from '../../base/PowerAutomateCommand.js';
13
+ class FlowRemoveCommand extends PowerAutomateCommand {
14
14
  get name() {
15
15
  return commands.REMOVE;
16
16
  }
@@ -30,7 +30,7 @@ class FlowRemoveCommand extends AzmgmtCommand {
30
30
  }
31
31
  const removeFlow = async () => {
32
32
  const requestOptions = {
33
- url: `${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
33
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
34
34
  fullResponse: true,
35
35
  headers: {
36
36
  accept: 'application/json'
@@ -9,9 +9,9 @@ import { aadGroup } from '../../../../utils/aadGroup.js';
9
9
  import { aadUser } from '../../../../utils/aadUser.js';
10
10
  import { formatting } from '../../../../utils/formatting.js';
11
11
  import { validation } from '../../../../utils/validation.js';
12
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
12
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
13
13
  import commands from '../../commands.js';
14
- class FlowOwnerEnsureCommand extends AzmgmtCommand {
14
+ class FlowOwnerEnsureCommand extends PowerAutomateCommand {
15
15
  get name() {
16
16
  return commands.OWNER_ENSURE;
17
17
  }
@@ -52,7 +52,7 @@ class FlowOwnerEnsureCommand extends AzmgmtCommand {
52
52
  type = 'Group';
53
53
  }
54
54
  const requestOptions = {
55
- url: `${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
55
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
56
56
  headers: {
57
57
  accept: 'application/json'
58
58
  },
@@ -8,9 +8,9 @@ import { cli } from '../../../../cli/cli.js';
8
8
  import { formatting } from '../../../../utils/formatting.js';
9
9
  import { odata } from '../../../../utils/odata.js';
10
10
  import { validation } from '../../../../utils/validation.js';
11
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
11
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
12
12
  import commands from '../../commands.js';
13
- class FlowOwnerListCommand extends AzmgmtCommand {
13
+ class FlowOwnerListCommand extends PowerAutomateCommand {
14
14
  get name() {
15
15
  return commands.OWNER_LIST;
16
16
  }
@@ -32,7 +32,7 @@ class FlowOwnerListCommand extends AzmgmtCommand {
32
32
  if (this.verbose) {
33
33
  await logger.logToStderr(`Listing owners for flow ${args.options.flowName} in environment ${args.options.environmentName}`);
34
34
  }
35
- const response = await odata.getAllItems(`${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/permissions?api-version=2016-11-01`);
35
+ const response = await odata.getAllItems(`${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/permissions?api-version=2016-11-01`);
36
36
  if (!cli.shouldTrimOutput(args.options.output)) {
37
37
  await logger.log(response);
38
38
  }
@@ -10,9 +10,9 @@ import { aadGroup } from '../../../../utils/aadGroup.js';
10
10
  import { aadUser } from '../../../../utils/aadUser.js';
11
11
  import { formatting } from '../../../../utils/formatting.js';
12
12
  import { validation } from '../../../../utils/validation.js';
13
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
13
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
14
14
  import commands from '../../commands.js';
15
- class FlowOwnerRemoveCommand extends AzmgmtCommand {
15
+ class FlowOwnerRemoveCommand extends PowerAutomateCommand {
16
16
  get name() {
17
17
  return commands.OWNER_REMOVE;
18
18
  }
@@ -47,7 +47,7 @@ class FlowOwnerRemoveCommand extends AzmgmtCommand {
47
47
  idToRemove = await aadGroup.getGroupIdByDisplayName(args.options.groupName);
48
48
  }
49
49
  const requestOptions = {
50
- url: `${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
50
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
51
51
  headers: {
52
52
  accept: 'application/json'
53
53
  },
@@ -8,9 +8,9 @@ import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
9
  import { formatting } from '../../../../utils/formatting.js';
10
10
  import { validation } from '../../../../utils/validation.js';
11
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
11
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
12
12
  import commands from '../../commands.js';
13
- class FlowRunCancelCommand extends AzmgmtCommand {
13
+ class FlowRunCancelCommand extends PowerAutomateCommand {
14
14
  get name() {
15
15
  return commands.RUN_CANCEL;
16
16
  }
@@ -30,7 +30,7 @@ class FlowRunCancelCommand extends AzmgmtCommand {
30
30
  }
31
31
  const cancelFlow = async () => {
32
32
  const requestOptions = {
33
- url: `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}/cancel?api-version=2016-11-01`,
33
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}/cancel?api-version=2016-11-01`,
34
34
  headers: {
35
35
  accept: 'application/json'
36
36
  },
@@ -7,9 +7,9 @@ var _FlowRunGetCommand_instances, _FlowRunGetCommand_initOptions, _FlowRunGetCom
7
7
  import request from '../../../../request.js';
8
8
  import { formatting } from '../../../../utils/formatting.js';
9
9
  import { validation } from '../../../../utils/validation.js';
10
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
10
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
11
11
  import commands from '../../commands.js';
12
- class FlowRunGetCommand extends AzmgmtCommand {
12
+ class FlowRunGetCommand extends PowerAutomateCommand {
13
13
  get name() {
14
14
  return commands.RUN_GET;
15
15
  }
@@ -31,7 +31,7 @@ class FlowRunGetCommand extends AzmgmtCommand {
31
31
  await logger.logToStderr(`Retrieving information about run ${args.options.name} of Microsoft Flow ${args.options.flowName}...`);
32
32
  }
33
33
  const requestOptions = {
34
- url: `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
34
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
35
35
  headers: {
36
36
  accept: 'application/json'
37
37
  },
@@ -5,10 +5,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _FlowRunListCommand_instances, _FlowRunListCommand_initTelemetry, _FlowRunListCommand_initOptions, _FlowRunListCommand_initValidators;
7
7
  import { formatting } from '../../../../utils/formatting.js';
8
+ import { odata } from '../../../../utils/odata.js';
8
9
  import { validation } from '../../../../utils/validation.js';
9
- import { AzmgmtItemsListCommand } from '../../../base/AzmgmtItemsListCommand.js';
10
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
10
11
  import commands from '../../commands.js';
11
- class FlowRunListCommand extends AzmgmtItemsListCommand {
12
+ class FlowRunListCommand extends PowerAutomateCommand {
12
13
  get name() {
13
14
  return commands.RUN_LIST;
14
15
  }
@@ -30,20 +31,20 @@ class FlowRunListCommand extends AzmgmtItemsListCommand {
30
31
  if (this.verbose) {
31
32
  await logger.logToStderr(`Retrieving list of runs for Microsoft Flow ${args.options.flowName}...`);
32
33
  }
33
- let url = `${this.resource}providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
34
+ let url = `${this.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
34
35
  const filters = this.getFilters(args.options);
35
36
  if (filters.length > 0) {
36
37
  url += `&$filter=${filters.join(' and ')}`;
37
38
  }
38
39
  try {
39
- await this.getAllItems(url, logger, true);
40
- if (args.options.output !== 'json' && this.items.length > 0) {
41
- this.items.forEach(i => {
40
+ const items = await odata.getAllItems(url);
41
+ if (args.options.output !== 'json' && items.length > 0) {
42
+ items.forEach(i => {
42
43
  i.startTime = i.properties.startTime;
43
44
  i.status = i.properties.status;
44
45
  });
45
46
  }
46
- await logger.log(this.items);
47
+ await logger.log(items);
47
48
  }
48
49
  catch (err) {
49
50
  this.handleRejectedODataJsonPromise(err);
@@ -9,9 +9,9 @@ import { cli } from '../../../../cli/cli.js';
9
9
  import request from '../../../../request.js';
10
10
  import { formatting } from '../../../../utils/formatting.js';
11
11
  import { validation } from '../../../../utils/validation.js';
12
- import AzmgmtCommand from '../../../base/AzmgmtCommand.js';
13
12
  import commands from '../../commands.js';
14
- class FlowRunResubmitCommand extends AzmgmtCommand {
13
+ import PowerAutomateCommand from '../../../base/PowerAutomateCommand.js';
14
+ class FlowRunResubmitCommand extends PowerAutomateCommand {
15
15
  get name() {
16
16
  return commands.RUN_RESUBMIT;
17
17
  }
@@ -36,7 +36,7 @@ class FlowRunResubmitCommand extends AzmgmtCommand {
36
36
  await logger.logToStderr(chalk.yellow(`Retrieved trigger: ${triggerName}`));
37
37
  }
38
38
  const requestOptions = {
39
- url: `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/triggers/${formatting.encodeQueryParameter(triggerName)}/histories/${formatting.encodeQueryParameter(args.options.name)}/resubmit?api-version=2016-11-01`,
39
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/triggers/${formatting.encodeQueryParameter(triggerName)}/histories/${formatting.encodeQueryParameter(args.options.name)}/resubmit?api-version=2016-11-01`,
40
40
  headers: {
41
41
  accept: 'application/json'
42
42
  },
@@ -60,7 +60,7 @@ class FlowRunResubmitCommand extends AzmgmtCommand {
60
60
  }
61
61
  async getTriggerName(environment, flow) {
62
62
  const requestOptions = {
63
- url: `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(environment)}/flows/${formatting.encodeQueryParameter(flow)}/triggers?api-version=2016-11-01`,
63
+ url: `${this.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(environment)}/flows/${formatting.encodeQueryParameter(flow)}/triggers?api-version=2016-11-01`,
64
64
  headers: {
65
65
  accept: 'application/json'
66
66
  },
@@ -29,6 +29,7 @@ class TeamsAppInstallCommand extends GraphCommand {
29
29
  async commandAction(logger, args) {
30
30
  try {
31
31
  await this.validateUser(args, logger);
32
+ const appId = await this.getAppId(args.options);
32
33
  let url = `${this.resource}/v1.0`;
33
34
  if (args.options.teamId) {
34
35
  url += `/teams/${formatting.encodeQueryParameter(args.options.teamId)}/installedApps`;
@@ -44,7 +45,7 @@ class TeamsAppInstallCommand extends GraphCommand {
44
45
  },
45
46
  responseType: 'json',
46
47
  data: {
47
- 'teamsApp@odata.bind': `${this.resource}/v1.0/appCatalogs/teamsApps/${args.options.id}`
48
+ 'teamsApp@odata.bind': `${this.resource}/v1.0/appCatalogs/teamsApps/${appId}`
48
49
  }
49
50
  };
50
51
  await request.post(requestOptions);
@@ -82,20 +83,45 @@ class TeamsAppInstallCommand extends GraphCommand {
82
83
  throw `User with ID ${args.options.userId} not found. Original error: ${err.error.message}`;
83
84
  }
84
85
  }
86
+ async getAppId(options) {
87
+ if (options.id) {
88
+ return options.id;
89
+ }
90
+ const requestOptions = {
91
+ url: `${this.resource}/v1.0/appCatalogs/teamsApps?$filter=displayName eq '${formatting.encodeQueryParameter(options.name)}'`,
92
+ headers: {
93
+ accept: 'application/json;odata.metadata=none'
94
+ },
95
+ responseType: 'json'
96
+ };
97
+ const response = await request.get(requestOptions);
98
+ const app = response.value[0];
99
+ if (!app) {
100
+ throw `The specified Teams app does not exist`;
101
+ }
102
+ if (response.value.length > 1) {
103
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
104
+ const result = await cli.handleMultipleResultsFound(`Multiple Teams apps with name ${options.name} found.`, resultAsKeyValuePair);
105
+ return result.id;
106
+ }
107
+ return app.id;
108
+ }
85
109
  }
86
110
  _TeamsAppInstallCommand_instances = new WeakSet(), _TeamsAppInstallCommand_initTelemetry = function _TeamsAppInstallCommand_initTelemetry() {
87
111
  this.telemetry.push((args) => {
88
112
  Object.assign(this.telemetryProperties, {
113
+ id: typeof args.options.id !== 'undefined',
114
+ name: typeof args.options.name !== 'undefined',
89
115
  teamId: typeof args.options.teamId !== 'undefined',
90
116
  userId: typeof args.options.userId !== 'undefined',
91
117
  userName: typeof args.options.userName !== 'undefined'
92
118
  });
93
119
  });
94
120
  }, _TeamsAppInstallCommand_initOptions = function _TeamsAppInstallCommand_initOptions() {
95
- this.options.unshift({ option: '--id <id>' }, { option: '--teamId [teamId]' }, { option: '--userId [userId]' }, { option: '--userName [userName]' });
121
+ this.options.unshift({ option: '-i, --id [id]' }, { option: '-n, --name [name]' }, { option: '--teamId [teamId]' }, { option: '--userId [userId]' }, { option: '--userName [userName]' });
96
122
  }, _TeamsAppInstallCommand_initValidators = function _TeamsAppInstallCommand_initValidators() {
97
123
  this.validators.push(async (args) => {
98
- if (!validation.isValidGuid(args.options.id)) {
124
+ if (args.options.id && !validation.isValidGuid(args.options.id)) {
99
125
  return `${args.options.id} is not a valid GUID`;
100
126
  }
101
127
  if (args.options.teamId &&
@@ -110,6 +136,7 @@ _TeamsAppInstallCommand_instances = new WeakSet(), _TeamsAppInstallCommand_initT
110
136
  });
111
137
  }, _TeamsAppInstallCommand_initOptionSets = function _TeamsAppInstallCommand_initOptionSets() {
112
138
  this.optionSets.push({ options: ['teamId', 'userId', 'userName'] });
139
+ this.optionSets.push({ options: ['id', 'name'] });
113
140
  };
114
141
  export default new TeamsAppInstallCommand();
115
142
  //# sourceMappingURL=app-install.js.map
@@ -3,8 +3,9 @@ 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 _TeamsUserAppAddCommand_instances, _TeamsUserAppAddCommand_initOptions, _TeamsUserAppAddCommand_initValidators;
6
+ var _TeamsUserAppAddCommand_instances, _TeamsUserAppAddCommand_initTelemetry, _TeamsUserAppAddCommand_initOptions, _TeamsUserAppAddCommand_initValidators, _TeamsUserAppAddCommand_initOptionSets;
7
7
  import request from '../../../../request.js';
8
+ import { formatting } from '../../../../utils/formatting.js';
8
9
  import { validation } from '../../../../utils/validation.js';
9
10
  import GraphCommand from '../../../base/GraphCommand.js';
10
11
  import commands from '../../commands.js';
@@ -18,13 +19,16 @@ class TeamsUserAppAddCommand extends GraphCommand {
18
19
  constructor() {
19
20
  super();
20
21
  _TeamsUserAppAddCommand_instances.add(this);
22
+ __classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initTelemetry).call(this);
21
23
  __classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initOptions).call(this);
22
24
  __classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initValidators).call(this);
25
+ __classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initOptionSets).call(this);
23
26
  }
24
27
  async commandAction(logger, args) {
28
+ const userId = (args.options.userId ?? args.options.userName);
25
29
  const endpoint = `${this.resource}/v1.0`;
26
30
  const requestOptions = {
27
- url: `${endpoint}/users/${args.options.userId}/teamwork/installedApps`,
31
+ url: `${endpoint}/users/${formatting.encodeQueryParameter(userId)}/teamwork/installedApps`,
28
32
  headers: {
29
33
  'content-type': 'application/json;odata=nometadata',
30
34
  'accept': 'application/json;odata.metadata=none'
@@ -42,22 +46,36 @@ class TeamsUserAppAddCommand extends GraphCommand {
42
46
  }
43
47
  }
44
48
  }
45
- _TeamsUserAppAddCommand_instances = new WeakSet(), _TeamsUserAppAddCommand_initOptions = function _TeamsUserAppAddCommand_initOptions() {
49
+ _TeamsUserAppAddCommand_instances = new WeakSet(), _TeamsUserAppAddCommand_initTelemetry = function _TeamsUserAppAddCommand_initTelemetry() {
50
+ this.telemetry.push((args) => {
51
+ Object.assign(this.telemetryProperties, {
52
+ userId: typeof args.options.userId !== 'undefined',
53
+ userName: typeof args.options.userName !== 'undefined'
54
+ });
55
+ });
56
+ }, _TeamsUserAppAddCommand_initOptions = function _TeamsUserAppAddCommand_initOptions() {
46
57
  this.options.unshift({
47
58
  option: '--id <id>'
48
59
  }, {
49
- option: '--userId <userId>'
60
+ option: '--userId [userId]'
61
+ }, {
62
+ option: '--userName [userName]'
50
63
  });
51
64
  }, _TeamsUserAppAddCommand_initValidators = function _TeamsUserAppAddCommand_initValidators() {
52
65
  this.validators.push(async (args) => {
53
66
  if (!validation.isValidGuid(args.options.id)) {
54
67
  return `${args.options.id} is not a valid GUID`;
55
68
  }
56
- if (!validation.isValidGuid(args.options.userId)) {
69
+ if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
57
70
  return `${args.options.userId} is not a valid GUID`;
58
71
  }
72
+ if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
73
+ return `${args.options.userName} is not a valid userName`;
74
+ }
59
75
  return true;
60
76
  });
77
+ }, _TeamsUserAppAddCommand_initOptionSets = function _TeamsUserAppAddCommand_initOptionSets() {
78
+ this.optionSets.push({ options: ['userId', 'userName'] });
61
79
  };
62
80
  export default new TeamsUserAppAddCommand();
63
81
  //# sourceMappingURL=user-app-add.js.map
@@ -1,7 +1,6 @@
1
- import { odata } from "./odata.js";
2
- import { formatting } from "./formatting.js";
3
- import { cli } from "../cli/cli.js";
4
- const graphResource = 'https://graph.microsoft.com';
1
+ import { odata } from './odata.js';
2
+ import { formatting } from './formatting.js';
3
+ import { cli } from '../cli/cli.js';
5
4
  export const aadAdministrativeUnit = {
6
5
  /**
7
6
  * Get an administrative unit by its display name.
@@ -10,6 +9,7 @@ export const aadAdministrativeUnit = {
10
9
  * @throws Error when administrative unit was not found.
11
10
  */
12
11
  async getAdministrativeUnitByDisplayName(displayName) {
12
+ const graphResource = 'https://graph.microsoft.com';
13
13
  const administrativeUnits = await odata.getAllItems(`${graphResource}/v1.0/directory/administrativeUnits?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
14
14
  if (administrativeUnits.length === 0) {
15
15
  throw `The specified administrative unit '${displayName}' does not exist.`;
@@ -0,0 +1,25 @@
1
+ import { odata } from "./odata.js";
2
+ import { formatting } from "./formatting.js";
3
+ import { cli } from "../cli/cli.js";
4
+ const graphResource = 'https://graph.microsoft.com';
5
+ export const aadDevice = {
6
+ /**
7
+ * Get a device by its display name.
8
+ * @param displayName Device display name.
9
+ * @returns The device.
10
+ * @throws Error when device was not found.
11
+ */
12
+ async getDeviceByDisplayName(displayName) {
13
+ const devices = await odata.getAllItems(`${graphResource}/v1.0/devices?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
14
+ if (devices.length === 0) {
15
+ throw `The specified device '${displayName}' does not exist.`;
16
+ }
17
+ if (devices.length > 1) {
18
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', devices);
19
+ const selectedDevice = await cli.handleMultipleResultsFound(`Multiple devices with name '${displayName}' found.`, resultAsKeyValuePair);
20
+ return selectedDevice;
21
+ }
22
+ return devices[0];
23
+ }
24
+ };
25
+ //# sourceMappingURL=aadDevice.js.map
@@ -0,0 +1,93 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+ import Tabs from '@theme/Tabs';
3
+ import TabItem from '@theme/TabItem';
4
+
5
+ # aad administrativeunit member add
6
+
7
+ Add a member (user, group, or device) to an administrative unit
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 aad administrativeunit member add [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-i, --administrativeUnitId [administrativeUnitId]`
19
+ : The id of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName` but not both.
20
+
21
+ `-n, --administrativeUnitName [administrativeUnitName]`
22
+ : The name of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName` but not both.
23
+
24
+ `--userId [userId]`
25
+ : The id of the user to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
26
+
27
+ `--userName [userName]`
28
+ : The user principal name (UPN) of the user to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
29
+
30
+ `--groupId [groupId]`
31
+ : The id of the group to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
32
+
33
+ `--groupName [groupName]`
34
+ : The name of the group to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
35
+
36
+ `--deviceId [deviceId]`
37
+ : The id of the device to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
38
+
39
+ `--deviceName [deviceName]`
40
+ : The name of the device to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
41
+ ```
42
+
43
+ <Global />
44
+
45
+ ## Remarks
46
+
47
+ :::info
48
+
49
+ To use this command you must be either **Global Administrator** or **Privileged Role Administrator**.
50
+
51
+ :::
52
+
53
+ ## Examples
54
+
55
+ Add a single user specified by id to an administrative unit specified by id
56
+
57
+ ```sh
58
+ m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --userId 1caf7dcd-7e83-4c3a-94f7-932a1299c844
59
+ ```
60
+
61
+ Add a single user specified by user principal name to an administrative unit specified by name
62
+
63
+ ```sh
64
+ m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --userName john.doe@contoso.com
65
+ ```
66
+
67
+ Add a single group specified by id to an administrative unit specified by id
68
+
69
+ ```sh
70
+ m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --groupId b2307a39-e878-458b-bc90-03bc578531d6
71
+ ```
72
+
73
+ Add a single group specified by name to an administrative unit specified by name
74
+
75
+ ```sh
76
+ m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --groupName 'Marketing Group'
77
+ ```
78
+
79
+ Add a single device specified by id to an administrative unit specified by id
80
+
81
+ ```sh
82
+ m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --deviceId 810c84a8-4a9e-49e6-bf7d-12d183f40d01
83
+ ```
84
+
85
+ Add a single device specified by name to an administrative unit specified by name
86
+
87
+ ```sh
88
+ m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --deviceName 'JohnDoe-PC'
89
+ ```
90
+
91
+ ## More information
92
+
93
+ - Administrative units: https://learn.microsoft.com/entra/identity/role-based-access-control/administrative-units