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.

Windowsdisk-cleanupFilespowershellLow risk
Run Get-ChildItem -Recurse -File piped to Sort-Object Length -Descending and Select-Object -First 20 to list the 20 biggest files.

01Command

Command
$ Get-ChildItem -Path C:\Users\me -Recurse -File | Sort-Object Length -Descending | Select-Object -First 20 Length, FullName

02What 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

RiskLow risk
RequirementsPowerShell
!Warning: Scanning all of C:\ recursively is slow and throws many access-denied errors; append -ErrorAction SilentlyContinue and point -Path at a user or project folder instead.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-ChildItem | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: 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 - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: 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