Find the twenty largest files below a folder
Build a paste-ready command, then review its compatibility and effects before running it.
Get-ChildItem . -File -Recurse -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 20 FullName,Lengthread-onlyno known side effects Compatibility
WindowsVerified for Windows using powershell syntax.
Operational knowledgereview due 2027-01-19
RequirementsGet-ChildItemGet-ChildItem must be installed and available on PATH.
Version supportGet-ChildItem Current supported releasesVerified for windows using powershell syntax; consult compatibility notes for platform-specific differences.
Expected signalsFullName LengthRepresentative successful output; values vary with the selected target and system state.
Known errorsGet-ChildItem: command not foundGet-ChildItem is missing or is not available on PATH.
VerifyGet-ChildItem {{folder}} -File -Recurse -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 20 FullName,LengthThe output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01Get-ChildItemCommandRuns the Get-ChildItem stage of this one-liner.
02<folder>ParameterA value supplied in the Fill parameters section.
03-FileOptionConfigures Get-ChildItem with the -File option.
04-RecurseOptionConfigures Get-ChildItem with the -Recurse option.
05-ErrorActionOptionConfigures Get-ChildItem with the -ErrorAction option.
06SilentlyContinueArgumentPasses SilentlyContinue to Get-ChildItem.
07|PipelinePasses the output on the left to the command on the right.
08Sort-ObjectCommandRuns the Sort-Object stage of this one-liner.
09LengthArgumentPasses Length to Sort-Object.
10-DescendingOptionConfigures Sort-Object with the -Descending option.
11|PipelinePasses the output on the left to the command on the right.
12Select-ObjectCommandRuns the Select-Object stage of this one-liner.
13-FirstOptionConfigures Select-Object with the -First option.
1420ArgumentPasses 20 to Select-Object.
15FullName,LengthArgumentPasses FullName,Length to Select-Object.
Example input
Get-ChildItem C:\Logs -File -Recurse -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 20 FullName,Length
Example output
FullName Length
-------- ------
C:\Logs\archive\api-2026-07-22.log 842194112
C:\Logs\web\access.log 284998451
C:\Logs\system\events.evtx 119537664
Illustrative output — exact values vary by system and data.
Official sources