Howtos / Articles

Display Total Folder Size with PowerShell and Sort by Size

The PowerShell command below can be used to display a list containing the total size (in MB) of all the files and folders (recursively) in the current directory, and sort them by total size. 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 Sample Output: TotalSize (MB) Mode Name ————– —- —- 26499…

Read more [...]