Skip to content

Commit

Permalink
perf(az): improve performance for az powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
tradiff authored and JanDeDobbeleer committed Apr 6, 2021
1 parent bb6a90a commit 4597f15
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/init/omp.ps1
Expand Up @@ -23,10 +23,20 @@ function global:Initialize-ModuleSupport {
$env:POSH_GIT_STATUS = Write-GitStatus -Status $global:GitStatus
}


if ($null -eq $env:AZ_ENABLED) {
if (Get-Module -ListAvailable -Name "Az.Accounts") {
$env:AZ_ENABLED = $true
}
else {
$env:AZ_ENABLED = $false
}
}

$env:AZ_SUBSCRIPTION_NAME = $null
$env:AZ_SUBSCRIPTION_ID = $null

if (Get-Module -ListAvailable -Name "Az.Accounts") {
if ($env:AZ_ENABLED -eq $true) {
try {
$subscription = Get-AzContext | Select-Object -ExpandProperty "Subscription" | Select-Object "Name", "Id"
if ($null -ne $subscription) {
Expand Down

0 comments on commit 4597f15

Please sign in to comment.