Skip to content

Instantly share code, notes, and snippets.

@jonschoning
Created August 16, 2011 14:48
Show Gist options
  • Save jonschoning/1149265 to your computer and use it in GitHub Desktop.
Save jonschoning/1149265 to your computer and use it in GitHub Desktop.
Get-SubDirSizes.ps1
function Get-SubDirSizes {
param([Parameter(Mandatory=$true)] [string] $path)
dir $path -force |
? { $_.PSIsContainer} |
% { new-object PsObject -property @{
Length = (dir $_.FullName -recurse -force | ? {! $_.PSIsContainer} | measure-object -sum Length).Sum;
Name = $_.Name
}
} |
sort Length -desc | ft Name,@{l="Size in MB"; e={[int]($_.Length/1MB)}} -autosize
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment