Look before you delete: three lines of reconnaissance
Cleanup without measurement is guessing. Get-Volume shows free space on every drive with one word, and the top-files line finds where the gigabytes actually live: Get-ChildItem C:\ -Recurse -File -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 20 FullName, @{n="MB";e={[math]::Round($_.Length/1MB)}}. Run it over the user profile instead of C:\ and it finishes in seconds rather than minutes. Add a second sort on LastWriteTime and the same line becomes an audit of what has been rotting untouched for years.
The folder-size one-liner is the line that replaces a GUI scanner for most people: Get-ChildItem $env:USERPROFILE -Directory | ForEach-Object { "{0,8:N2} GB {1}" -f ((Get-ChildItem $_.FullName -Recurse -File -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum/1GB), $_.Name }. It walks every folder in your profile, sums the files and prints gigabytes to two decimals. On a big profile it takes a few minutes, because it stat()s every file — the same work any disk-usage tool does, just without the install. The last recon line is an audit rather than a deletion: Get-ChildItem "$env:USERPROFILE\Downloads" -Recurse -File | Where-Object LastWriteTime -lt (Get-Date).AddMonths(-6) lists everything in Downloads older than half a year; append Sort-Object LastWriteTime and it goes oldest first.
Safe cuts that need no admin window
These four need nothing but your normal user session, and each one skips files that are currently in use rather than failing on them. The temp wipe, the Recycle Bin and the crash-dump purge together routinely free several gigabytes on a machine that has never been cleaned. Before any of them, append -WhatIf to the Remove-Item line and read what it would have deleted — the habit costs ten seconds and prevents every wrong-folder story.
- Remove-Item $env:TEMP\* -Recurse -Force -ErrorAction SilentlyContinue — user temp; locked files are skipped automatically
- Clear-RecycleBin -Force — the bin on every drive, emptied in one line
- Get-ChildItem $env:LOCALAPPDATA\CrashDumps -File | Remove-Item -Force — .dmp files no one will ever open
- Remove-Item "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\thumbcache_*.db" -Force — the thumbnail cache; close Explorer windows first
- Get-ChildItem "$env:USERPROFILE\Downloads" -File | Where-Object LastWriteTime -lt (Get-Date).AddMonths(-6) — the Downloads audit from the section above, ready for review
The deep cuts: admin window and real respect
Open Windows Terminal (Admin) with Win+X for these. Under the same Remove-Item pattern, C:\Windows\Temp\* yields another tranche of junk; Delete-DeliveryOptimizationCache -Force clears the peer-to-peer update cache that Disk Cleanup historically missed; DISM /Online /Cleanup-Image /StartComponentCleanup is the only supported way to shrink WinSxS — add /ResetBase only if you accept that installed updates become permanent. powercfg /h off deletes hiberfil.sys, roughly 40% of your RAM in gigabytes, if you never hibernate; powercfg /h /type reduced keeps Fast Startup at half the price.
The last one stops the update services, wipes their download cache and restarts them, which repairs stuck updates as a bonus: Stop-Service wuauserv, bits -ErrorAction SilentlyContinue; Remove-Item C:\Windows\SoftwareDistribution\Download\* -Recurse -Force -ErrorAction SilentlyContinue; Start-Service wuauserv, bits. If keeping thirteen lines in a notes file is not your style, a cleanup tool such as Kleaner PRO runs the safe half of this list on a schedule and leaves the deep cuts to you. Either way, measure first — the recon lines are what turn cleaning from a ritual into a decision.
Questions and Answers
How do I clean temp files with PowerShell?
Run Remove-Item $env:TEMP\* -Recurse -Force -ErrorAction SilentlyContinue; files in use are skipped, and a -WhatIf beforehand prints what would go. The same pattern works on C:\Windows\Temp in an admin window.
Is DISM StartComponentCleanup safe to run?
Yes — it is the supported way to shrink the WinSxS component store, and Windows runs it on its own schedule anyway. Add /ResetBase only with the caveat that installed updates can no longer be uninstalled.
Know what is included before you buy.
The one-time 30-minute trial covers core tools. PRO-labelled features stay locked until a paid license is activated.
Read next
Write to us: [email protected]