@@ -22,38 +22,39 @@ class ScriptBuilder {
2222 if ( scheme === Constants_1 . default . ServicePrincipal ) {
2323 command += `Connect-AzAccount -ServicePrincipal -Tenant ${ tenantId } -Credential \
2424 (New-Object System.Management.Automation.PSCredential('${ args . servicePrincipalId } ',(ConvertTo-SecureString ${ args . servicePrincipalKey } -AsPlainText -Force))) \
25- -Environment ${ args . environment } ;` ;
25+ -Environment ${ args . environment } | out-null ;` ;
2626 if ( args . scopeLevel === Constants_1 . default . Subscription ) {
27- command += `Set-AzContext -SubscriptionId ${ args . subscriptionId } -TenantId ${ tenantId } ;` ;
27+ command += `Set-AzContext -SubscriptionId ${ args . subscriptionId } -TenantId ${ tenantId } | out-null ;` ;
2828 }
2929 }
30- command += `Get-AzContext` ;
3130 this . script += `try {
32- $$ErrorActionPreference = "Stop";
33- $$output = @{};
31+ $ErrorActionPreference = "Stop"
32+ $WarningPreference = "SilentlyContinue"
33+ $output = @{}
3434 ${ command }
35- $$ output['${ Constants_1 . default . Success } '] = "true";
35+ $output['${ Constants_1 . default . Success } '] = "true"
3636 }
3737 catch {
38- $$ output['${ Constants_1 . default . Error } '] = $$ _.exception.Message;
38+ $output['${ Constants_1 . default . Error } '] = $_.exception.Message
3939 }
40- return ConvertTo-Json $$a ` ;
40+ return ConvertTo-Json $output ` ;
4141 core . debug ( `Azure PowerShell Login Script: ${ this . script } ` ) ;
4242 return this . script ;
4343 }
4444 getLatestModuleScript ( moduleName ) {
4545 const command = `Get-Module -Name ${ moduleName } -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1` ;
4646 this . script += `try {
47- $$ErrorActionPreference = "Stop";
48- $$output = @{};
49- $$data = ${ command } ;
50- $$output['${ Constants_1 . default . AzVersion } '] = $$data.Version.ToString();
51- $$output['${ Constants_1 . default . Success } '] = "true";
47+ $ErrorActionPreference = "Stop"
48+ $WarningPreference = "SilentlyContinue"
49+ $output = @{}
50+ $data = ${ command }
51+ $output['${ Constants_1 . default . AzVersion } '] = $data.Version.ToString()
52+ $output['${ Constants_1 . default . Success } '] = "true"
5253 }
5354 catch {
54- $$ output['${ Constants_1 . default . Error } '] = $$ _.exception.Message;
55+ $output['${ Constants_1 . default . Error } '] = $_.exception.Message
5556 }
56- return ConvertTo-Json $$a ` ;
57+ return ConvertTo-Json $output ` ;
5758 core . debug ( `GetLatestModuleScript: ${ this . script } ` ) ;
5859 return this . script ;
5960 }
0 commit comments