microsoft/TypeAgent

Public

mirrored from https://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f1e34e25779b3a0e8cf9ef9b59f5d1877e1c8016

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ts/tools/scripts/elevate.js

54lines · modecode

1#!/usr/bin/env node
2// Copyright (c) Microsoft Corporation.
3// Licensed under the MIT License.
4
5const config = require("./elevate.config.json");
6
7async function elevate() {
8 const { getClient } = await import("./lib/pimClient.mjs");
9
10 // get PIM client
11 const client = await getClient();
12
13 // elevate
14 await config.forEach((element) => {
15 var v = client.elevate({
16 requestType: element.properties.RequestType,
17 roleName: element.roleName,
18 expirationType: element.properties.ScheduleInfo.Expiration.Type,
19 expirationDuration:
20 element.properties.ScheduleInfo.Expiration.Duration,
21 });
22 });
23}
24
25(async () => {
26 const command = process.argv[2];
27 switch (command) {
28 case "help":
29 console.log("elevate");
30 console.log(
31 "Uses the logged in account to elevate. Will prompt for login if the user is not logged in.",
32 );
33 console.log("Uses configuration from elevate.config.json.");
34 return;
35 default:
36 await elevate();
37 break;
38 }
39})().catch((e) => {
40 if (
41 e.message.includes(
42 "'az' is not recognized as an internal or external command",
43 )
44 ) {
45 console.error(
46 `ERROR: Azure CLI is not installed. Install it and run 'az login' before running this tool.`,
47 );
48
49 exit(0);
50 }
51
52 console.error(`FATAL ERROR: ${e.stack}`);
53 process.exit(-1);
54});
55