PowerShell Script
Find Largest Files
A safe example of the future script-detail layout: purpose, environment, copy button, usage and safety notes.
WindowsPowerShell 5.1+Read-only
What problem it solves
Quickly lists the largest files under a folder so an administrator can see where disk space is being used. The example only reads file metadata.
$Path = "C:\Users\Public\Documents"
$Top = 20
Get-ChildItem -Path $Path -File -Recurse -ErrorAction SilentlyContinue |
Sort-Object Length -Descending |
Select-Object -First $Top `
@{Name="SizeMB";Expression={[math]::Round($_.Length / 1MB, 2)}},
FullName |
Format-Table -AutoSizeUsage
- Change
$Pathto the folder you want to inspect. - Change
$Topif you want more or fewer results. - Run in PowerShell with access to the selected folder.
Safety note
This preview script does not delete or modify files. Production script pages will explicitly identify elevated privileges, write operations and environment-specific risks.