Page 1 of 1

One liner PowerShell for getting directory size (in GB)

New postPosted: Wed Dec 28, 2016 6:21 pm
by 3ICE
Code: Select all
'{0:0.0} GiB' -f (((Get-ChildItem -Recurse | Measure-Object -Sum Length).Sum) / 1GB)

Shortest form:
Code: Select all
'{0:0.0} GiB' -f (((ls -r | measure -s Length).Sum) / 1GB)


In action:
One liner PowerShell for getting directory size (in GB).png
One liner PowerShell for getting directory size (in GB).png (5.35 KiB) Viewed 474 times

(Shows 1.7 GB, which is correct.)