Find the largest files in a folder with PowerShell
Recursively list files sorted by size, largest first, to hunt down disk-space hogs in any directory tree.
01Command
$ Get-ChildItem -Path C:\Users\me -Recurse -File | Sort-Object Length -Descending | Select-Object -First 20 Length, FullName02What it does
Every file returned by Get-ChildItem carries a Length property in bytes. Sorting on it descending and taking the first N items gives an instant 'what's biggest' report. Add @{n='MB';e={[math]::Round($_.Length/1MB,1)}} to Select-Object if you want megabytes instead of raw bytes. This is the quick alternative to WinDirStat/TreeSize for one-off checks.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Get-ChildItem | Microsoft LearnEvidence: Microsoft documents Get-ChildItem with -Recurse and -File, and that FileInfo objects expose the Length property, which can be sorted with Sort-Object.
- Get-ChildItem - PowerShellEvidence: SS64 shows Get-ChildItem piped into Sort-Object and Select-Object to rank files, e.g. by file size.
Last verified: 2026-09-17 · 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.