Skip to content

Instantly share code, notes, and snippets.

@joanteixi
Created October 4, 2022 08:43
Show Gist options
  • Save joanteixi/9161d4c2b3a11ff507515f4c807ce4b7 to your computer and use it in GitHub Desktop.
Save joanteixi/9161d4c2b3a11ff507515f4c807ce4b7 to your computer and use it in GitHub Desktop.
Azure Storage get size by folder
# Run first "connect-azAccount" to set AAD user authentication
$filesystemName = 'storageFilesystem'
$path = 'folder'
$storageName = 'storagName'
$ctx = New-AzStorageContext -StorageAccountName $storageName -UseConnectedAccount
$Files = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $filesystemName -Path $path -Recurse | Where-Object IsDirectory -eq $false
$Total = $Files | Measure-Object -Property Length -Sum
$Total | Select-Object @{Name = "SizeInGb"; Expression={$_.Sum/1GB}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment