locked
Get the size of ALL storage in a subscription RRS feed

  • Question

  • Hey Everyone,

    I want to get the size of all the storage blobs currently on in a subscription. I've been trying to do it in powershell and the best I've been able to do so far is manually enter in each blob and get storage results. I'd like to be able to run one script that does it all for me. 

    Wednesday, July 24, 2019 5:40 PM

All replies

  • Try this one out:

    # Get the current subscription
    Connect-AzAccount

    $storageAccounts=Get-AzStorageAccount 
    ForEach($storageAccount in $storageAccounts)
    {
    $ctx = $storageAccount.Context 
    $Containers = Get-AzStorageContainer -Context $ctx 
    ForEach($Container in $Containers)
    {
    # get a list of all of the blobs in the container 
    $listOfBLobs = Get-AzStorageBlob -Container $Container.Name -Context $ctx 
    $listOfBlobs | ForEach-Object {Write-Host $_.Name  " blob length is: " $_.Length}
    }
    }


    Shweta Naganath

    Wednesday, July 24, 2019 8:53 PM
  •  @LtDanMT Just checking in to see if the above answer helped. If this answers your query, do click “Mark as Answer” and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.
    Monday, July 29, 2019 5:27 AM
  • @LtDanMTIs there any update on the issue?

    If the suggested answer helped for your issue, do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Tuesday, July 30, 2019 9:56 AM
  • Is there any update on the issue?

    If the suggested answer helped for your issue, do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Tuesday, August 6, 2019 10:41 AM