Tuesday, October 22, 2024

Listing directories and their sizes on Windows

All credits go to superuser answer.

Get-ChildItem | Where-Object { $_.PSIsContainer } | ForEach-Object { $_.Name + ": " + "{0:N2}" -f ((Get-ChildItem $_ -Recurse | Measure-Object Length -Sum -ErrorAction SilentlyContinue).Sum / 1MB) + " MB" }

No comments:

Post a Comment