@Harish Ch Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.
$sub = Get-AzSubscription | select Name
$sub | foreach {
Set-AzContext -Subscription $_.Name
$currentSub = $_.Name
$RGs = Get-AzResourceGroup | select ResourceGroupName
$RGs | foreach {
$CurrentRG = $_.ResourceGroupName
$StorageAccounts = Get-AzStorageAccount -ResourceGroupName $CurrentRG | select StorageAccountName
$StorageAccounts | foreach {
$StorageAccount = $_.StorageAccountName
$CurrentSAID = (Get-AzStorageAccount -ResourceGroupName $CurrentRG -AccountName $StorageAccount).Id
$usedCapacity = (Get-AzMetric -ResourceId $CurrentSAID -MetricName "UsedCapacity").Data
$usedCapacityInMB = $usedCapacity.Average / 1024 / 1024
"$StorageAccount,$usedCapacityInMB,$CurrentRG,$currentSub" >> ".\storageAccountsUsedCapacity.csv"
}
}
}
You can also view through Azure Portal
Hope this helps!
Kindly let us know if the above helps or you need further assistance on this issue.
---------------------------------------------------------------------------------------------------------------------
Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.