Skip to content

Instantly share code, notes, and snippets.

@a4099181
Created August 5, 2019 09:36
Show Gist options
  • Save a4099181/f620aeb79d485603aae908bf985ac8fe to your computer and use it in GitHub Desktop.
Save a4099181/f620aeb79d485603aae908bf985ac8fe to your computer and use it in GitHub Desktop.
Powershell script to calculate directory size. Lists all directories in a current directory. Calculates and prints a size for each of them (dirstat, folder statistics).
Get-ChildItem -Directory |
Select-Object `
@{ N="Directory"; E={ $_.Name } }, `
@{ N="Size"; E={ (Get-ChildItem -Recurse -File -Path $_.FullName | Measure-Object -Property Length -Sum).Sum } } |
Sort-Object -Property Size -Descending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment