Text in, text out: the limit that broke a thousand batch files
cmd is a text shell: dir prints formatted columns, and anything you actually wanted — a size, a date, a name — arrives as characters glued to a page you then have to cut apart. Scripts built on that parsing break the day a locale spells a month differently, a column widens, or a filename carries a space. Anyone who maintained batch files remembers the ritual: FOR /F with tokens and delimiters, a small prayer, and a second version for machines that answer in another language.
PowerShell, shipped in 2006 and built on .NET, was designed to end exactly that. Get-ChildItem does not print lines — it returns FileInfo objects that carry Name, Length, LastWriteTime and Extension as data. The pipeline between commands passes those objects whole, so a filter written in Moscow runs identically in Munich, and a sum is a number you can round and format, not a string you have to trust.
Verb-noun cmdlets that compose the way cleanup tools should
Commands here are cmdlets named Verb-Noun — Get-ChildItem, Where-Object, Measure-Object, Remove-Item — and the discipline is not cosmetic: approved verbs keep a pipeline readable half a year later, the way a labeled toolbox beats a drawer of mystery screwdrivers. For cleanup, composition matters more than any single command: find, filter, measure, delete is one line of object flow instead of four paragraphs of batch syntax. Each stage names itself too, so a one-liner written in a hurry still reads like a sentence a month later.
The quieter win is safety. Remove-Item accepts -WhatIf, which prints every deletion it would perform and then performs none, and -Confirm, which asks file by file — dry runs cmd simply never had. Get-AppxPackage pipes straight into Remove-AppxPackage, so removing a bundled app is a pipeline rather than a registry hunt. That does not make deletion harmless, but it makes it inspectable, which is the property cleanup scripts always lacked.
- Get-ChildItem $env:TEMP -Recurse — a FileInfo object per file, with Length and LastWriteTime as data
- Where-Object Length -gt 100MB — a filter on objects, immune to locale and column width
- Measure-Object Length -Sum — the gigabyte total as a number, not a string to re-parse
- Remove-Item ... -WhatIf — a dry run that lists every deletion it would perform
- Get-AppxPackage *zune* | Remove-AppxPackage — appx removal as one pipeline
Where cmd still wins, and the honest limits
PowerShell is not free. It starts slower than cmd, its execution policy stops newcomers who run a downloaded .ps1 before Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, and a recursive Get-ChildItem across an entire drive crawls next to purpose-built scanners. For the classics — ipconfig, sfc, powercfg — cmd remains the lighter window, and nothing here retires those twenty commands.
The other honest limit is concurrency: deletion runs on one thread, so a huge tree of small files takes the time it takes. The balance is still clear. For anything that measures, filters or reports before it deletes, PowerShell treats your system as data instead of a screen to scrape — and the one-liners in our follow-up post need nothing beyond copy-paste.
Questions and Answers
Is PowerShell better than cmd for cleaning up Windows?
For anything that filters, measures or dry-runs deletions, yes: object pipelines survive any locale and report before acting. For the network and repair classics — ipconfig, sfc, chkdsk — cmd remains the lighter window.
What is the difference between Windows PowerShell and PowerShell 7?
Windows PowerShell 5.1 ships inside the OS on .NET Framework; PowerShell 7 is the cross-platform successor you install separately. Cleanup one-liners run unchanged in both.
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]