diff --git a/PackageHandling/Install-AzDevops.ps1 b/PackageHandling/Install-AzDevops.ps1 index 491a28367..89cab86e8 100644 --- a/PackageHandling/Install-AzDevops.ps1 +++ b/PackageHandling/Install-AzDevops.ps1 @@ -8,12 +8,16 @@ function Install-AzDevops { Param( ) -$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() -try { +$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() +try { Try { - az upgrade + $az_upgrade = Write-Output n | az upgrade 2>&1 } catch { + $az_upgrade = "" + } + + if (@($az_upgrade | Select-String "Latest version available").Count -ne 0) { Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi } $extensions = az extension list -o json | ConvertFrom-Json @@ -29,13 +33,13 @@ try { if ($devopsFound -eq $False){ az extension add -n azure-devops } -} -catch { - TrackException -telemetryScope $telemetryScope -errorRecord $_ - throw -} -finally { - TrackTrace -telemetryScope $telemetryScope +} +catch { + TrackException -telemetryScope $telemetryScope -errorRecord $_ + throw +} +finally { + TrackTrace -telemetryScope $telemetryScope } } Export-ModuleMember -Function Install-AzDevops