Get a Folder's Total Size with PowerShell (du for Windows)
Sum file sizes recursively with Get-ChildItem and Measure-Object Length -Sum to see how much space a folder occupies.
01Command
$ "{0:N2} MB" -f ((Get-ChildItem 'C:\Users\me\Downloads' -Recurse -File -Force -ErrorAction SilentlyContinue |
Measure-Object Length -Sum).Sum / 1MB)02What it does
Windows File Explorer's folder Properties shows size, but from the command line the standard equivalent of du is piping Get-ChildItem -Recurse -File into Measure-Object Length -Sum. -Force includes hidden files, and -ErrorAction SilentlyContinue skips folders you can't read (like system-protected ones) instead of aborting. Divide by 1MB or 1GB to make the raw byte count readable; to compare many folders at once, group the results per top-level directory.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Measure-ObjectEvidence: Measure-Object Length -Sum totals the file sizes piped from Get-ChildItem, the standard way to compute folder size in PowerShell.
- Measure-Object - SS64Evidence: Shows -Sum aggregation of numeric properties like file Length.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.
Robocopy is Windows' built-in robust file copier: use /MIR to keep a destination folder as an exact one-way mirror of a source, resumable and restartable.
Search inside text files and logs with regex, returning file, line number and match.