I was wondering is there a reliable PowerShell script that gets Used Capacity for a storage account in Azure? Current script we are using is inconsistent- sometimes it returns results and sometimes it is blank values.
The script here works fine, just sometimes returns blank values for some accounts, or all.
Script:
#CAPACITY
$SAID = $storageAccount.Id
$usedCapacity = (Get-AzMetric -ResourceId $SAID -MetricName "UsedCapacity").Data
$usedCapacityInMB = $usedCapacity.Average/1024/1024
Many thanks everyone for your help!
Your script is correct (and you can find examples of other Stack Overflow users using it as well), but unfortunately, this is a known issue . Although it doesn't help from a scripting standpoint, it should be noted that this doesn't seem to affect the portal.
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.