Skip to content

Instantly share code, notes, and snippets.

@MarcStoecker
Created March 7, 2013 16:36
Show Gist options
  • Save MarcStoecker/5109419 to your computer and use it in GitHub Desktop.
Save MarcStoecker/5109419 to your computer and use it in GitHub Desktop.
Display Total Folder Size with PowerShell and Sort by Size (can take a while if many levels to work down to)
ls -Force | Add-Member -Force -Passthru -Type ScriptProperty -Name Length -Value {ls $this -Recurse -Force | Measure -Sum Length | Select -Expand Sum } | Sort-Object Length -Descending | Format-Table @{label="TotalSize (MB)";expression={[Math]::Truncate($_.Length / 1MB)};width=14}, @{label="Mode";expression={$_.Mode};width=8}, Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment