Share via


Azure PowerShell: Get-AzVMUsage on Azure locations

 

# How to get Get-AzVMUsage on Azure locations

########################################### ######################

$locations = Get-Content -Path "C:\users\Satya\Desktop\locations.txt"

 

foreach ($loc in $locations)

   Write-Host "$loc" -ForegroundColor Green

   Get-AzVMUsage -Location $loc | select @{label="Name";expression={$_.name.LocalizedValue}},currentvalue,limit, @{label="PercentageUsed";expression={[math]::Round(($_.currentvalue/$_.limit)*100,1)}},@{label="Location";expression={$loc}} | ft -AutoSize

}

###################################################################