microsoft/TypeAgent

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2994984482e393f4eb17ab99eae140fb10cd6261

Branches

Tags

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

Clone

HTTPS

Download ZIP

ts/tools/scripts/elevate.js

51lines · 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 var v = await client.elevate({
15 requestType: config.properties.RequestType,
16 roleName: config.roleName,
17 expirationType: config.properties.ScheduleInfo.Expiration.Type,
18 expirationDuration: config.properties.ScheduleInfo.Expiration.Duration,
19 });
20}
21
22(async () => {
23 const command = process.argv[2];
24 switch (command) {
25 case "help":
26 console.log("elevate");
27 console.log(
28 "Uses the logged in account to elevate. Will prompt for login if the user is not logged in.",
29 );
30 console.log("Uses configuration from elevate.config.json.");
31 return;
32 default:
33 await elevate();
34 break;
35 }
36})().catch((e) => {
37 if (
38 e.message.includes(
39 "'az' is not recognized as an internal or external command",
40 )
41 ) {
42 console.error(
43 `ERROR: Azure CLI is not installed. Install it and run 'az login' before running this tool.`,
44 );
45
46 exit(0);
47 }
48
49 console.error(`FATAL ERROR: ${e.stack}`);
50 process.exit(-1);
51});
52