mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
Added changes for review comments
This commit is contained in:
@@ -11,22 +11,22 @@ export default class ScriptBuilder {
|
||||
if (scheme === Constants.ServicePrincipal) {
|
||||
command += `Connect-AzAccount -ServicePrincipal -Tenant ${tenantId} -Credential \
|
||||
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString ${args.servicePrincipalKey} -AsPlainText -Force))) \
|
||||
-Environment ${args.environment};`;
|
||||
-Environment ${args.environment} | out-null;`;
|
||||
if (args.scopeLevel === Constants.Subscription) {
|
||||
command += `Set-AzContext -SubscriptionId ${args.subscriptionId} -TenantId ${tenantId};`;
|
||||
command += `Set-AzContext -SubscriptionId ${args.subscriptionId} -TenantId ${tenantId} | out-null;`;
|
||||
}
|
||||
}
|
||||
command += `Get-AzContext`;
|
||||
this.script += `try {
|
||||
$$ErrorActionPreference = "Stop";
|
||||
$$output = @{};
|
||||
$ErrorActionPreference = "Stop"
|
||||
$WarningPreference = "SilentlyContinue"
|
||||
$output = @{}
|
||||
${command}
|
||||
$$output['${Constants.Success}'] = "true";
|
||||
$output['${Constants.Success}'] = "true"
|
||||
}
|
||||
catch {
|
||||
$$output['${Constants.Error}'] = $$_.exception.Message;
|
||||
$output['${Constants.Error}'] = $_.exception.Message
|
||||
}
|
||||
return ConvertTo-Json $$a`;
|
||||
return ConvertTo-Json $output`;
|
||||
core.debug(`Azure PowerShell Login Script: ${this.script}`);
|
||||
return this.script;
|
||||
}
|
||||
@@ -34,16 +34,17 @@ export default class ScriptBuilder {
|
||||
getLatestModuleScript(moduleName: string): string {
|
||||
const command: string = `Get-Module -Name ${moduleName} -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1`;
|
||||
this.script += `try {
|
||||
$$ErrorActionPreference = "Stop";
|
||||
$$output = @{};
|
||||
$$data = ${command};
|
||||
$$output['${Constants.AzVersion}'] = $$data.Version.ToString();
|
||||
$$output['${Constants.Success}'] = "true";
|
||||
$ErrorActionPreference = "Stop"
|
||||
$WarningPreference = "SilentlyContinue"
|
||||
$output = @{}
|
||||
$data = ${command}
|
||||
$output['${Constants.AzVersion}'] = $data.Version.ToString()
|
||||
$output['${Constants.Success}'] = "true"
|
||||
}
|
||||
catch {
|
||||
$$output['${Constants.Error}'] = $$_.exception.Message;
|
||||
$output['${Constants.Error}'] = $_.exception.Message
|
||||
}
|
||||
return ConvertTo-Json $$a`;
|
||||
return ConvertTo-Json $output`;
|
||||
core.debug(`GetLatestModuleScript: ${this.script}`);
|
||||
return this.script;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user