On paper, the pitch is catnip for anyone tired of bloated system-tray utilities, nagware upsells, and dubious "registry fix" promises. In Khan's single-machine test on a 256 GB C: drive, running the generated script on top of Storage Sense bumped available space from 19.6 GB to 24.4 GB—a 4.8 GB gain. Before you rush to paste an AI-written deletion script into an elevated PowerShell window, though, it pays to pop the hood. A close look at the code MakeUseOf published reveals a sharp divide between a genuinely useful cleanup inventory and a handful of subtle bugs, overstated measurements, and Windows servicing trade-offs that deserve a veteran admin's scrutiny.
Why Third-Party PC Cleaners Lost Their Edge on Windows 11
For decades, utilities like CCleaner thrived on a simple pitch: Windows left digital lint everywhere, and only a dedicated cleaner could sweep it up—ideally alongside a "registry repair" button that made users feel productive. On modern Windows 11, that value proposition has largely evaporated. Microsoft's official support policy on registry cleaning utilities (KB2563254) explicitly warns against using tools that rely on unsupported methods to extract or modify registry contents, noting that improper edits can cause serious instability severe enough to require reinstalling the operating system. Meanwhile, Microsoft's own built-in storage tooling already handles the core temporary-file sweep without installing a persistent background service or system-tray monitor.
Khan's prompt to Claude leaned directly into that philosophy:
- No registry edits: Leave Windows Registry keys untouched, avoiding unnecessary risk.
- No game-cache purging: Keep shader and game-launcher caches intact.
- Cover Storage Sense's blind spots: Target browser caches, third-party app caches, crash dumps, Windows logs, temp directories, and the Recycle Bin.
- Safety and accountability guardrails: Request administrator privileges, skip locked files in use, support a
-DryRunpreview and a-Scheduleswitch for weekly execution, and append a timestamped summary toCleanupLog.txtin the user's Documents folder.
It is a remarkably sensible specification—precisely because it treats cleanup as transparent file-system hygiene rather than black-box "optimization."
What Storage Sense Actually Does (and Doesn't Do)
MakeUseOf frames Storage Sense as a background tool scheduled to run weekly, though Microsoft Support documentation notes that out of the box, Storage Sense defaults to running only when disk space drops low. Weekly, daily, and monthly cadences are user- or administrator-configured options inside Settings > System > Storage > Storage Sense (or via Intune, CSP, and Group Policy).
More importantly, Microsoft's documentation highlights two structural boundaries in Storage Sense that explain why a supplemental script can still reclaim gigabytes:
- System-drive scope: Storage Sense operates strictly on the system drive containing Windows (typically
C:). - Conservative defaults and narrow app coverage: By default, Storage Sense clears temporary system files and aged Recycle Bin items, leaving the Downloads folder and OneDrive cloud-backed files untouched unless you explicitly configure retention thresholds. It does not chase down third-party Electron or Chromium app caches scattered across
%LOCALAPPDATA%and%APPDATA%.
Section Takeaway: Walking away from third-party cleanup suites on Windows 11 makes practical sense, especially given Microsoft's warnings against registry cleaners. Storage Sense covers core OS hygiene automatically, but it leaves third-party application caches largely alone.
Inside Claude's PowerShell Cleanup Script
To bridge those gaps, Claude generated a script targeting PowerShell 5.1 or later (#Requires -Version 5.1) with [CmdletBinding()] parameters for -DryRun and -Schedule. When executed without administrator rights, it re-launches itself via Start-Process powershell.exe -Verb RunAs while passing along -DryRun or -Schedule switches and -ExecutionPolicy Bypass. (Worth noting for enterprise or managed PCs: as Microsoft's about_Execution_Policies guidance explains, Bypass skips signature checks at the process level, but Group Policy scopes like MachinePolicy and UserPolicy still take precedence.)
Here is what the script's $targets array actually sweeps:
- System and user temp files:
%TEMP%,C:\Windows\Temp, Windows thumbnail databases (thumbcache_*.db), and legacyINetCache. - Web browser caches: Firefox profile
cache2folders, plusCache,Code Cache,GPUCache, andService Worker\CacheStorageacross Google Chrome, Microsoft Edge, and Brave. - Messaging, media, and creative apps: Discord (
Cache,Code Cache), Slack (Cache,Code Cache), Microsoft Teams (Cache), Spotify (Storage), and Adobe (Media Cache Files). - Developer package caches:
npm-cache,pip\Cache, andNuGet\v3-cache. - Windows servicing, update, and crash diagnostics:
SoftwareDistribution\Download, Delivery OptimizationCache, Windows Error Reporting (WER), userCrashDumps,Minidump,LiveKernelReports,MEMORY.DMP, and Component-Based Servicing logs (C:\Windows\Logs\CBS). - Recycle Bin: Measures
C:\$Recycle.Binand invokesClear-RecycleBin -DriveLetter C -Forcein live mode.
Before deleting anything, the script enumerates each target, prints a descending table in gigabytes, temporarily stops running wuauserv, bits, and DoSvc services during a live run (restarting only the ones that were originally active in a finally block), and logs a single summary line to CleanupLog.txt.
How It Compares to Built-In Windows Tools
| Cleanup Area | Storage Sense (Built-In) | Disk Cleanup (cleanmgr.exe) + DISM | Claude PowerShell Script |
|---|---|---|---|
| User & Windows Temp Files | Yes | Yes | Yes |
| Recycle Bin | Configurable day threshold | Yes | Yes (C: drive only) |
| Delivery Optimization & Update Cache | Limited / automated cache expiry | Yes (with System Files + StartComponentCleanup) | Yes (stops wuauserv, bits, DoSvc) |
| Third-Party Browser & App Caches | No | No (Edge/IE temp files only) | Yes (Chrome, Edge, Brave, Firefox, Discord, Slack, Spotify, Adobe, dev tools) |
| Crash Dumps & CBS Logs | Partial (WER/temp depending on settings) | Yes (WER & upgrade logs) | Yes (deletes CBS logs, Minidump, MEMORY.DMP) |
| Registry Cleaning | No | No | No |
| Unattended Reliability | Native Windows service | Manual unless scripted via /sagerun | Needs fixes (contains interactive Read-Host) |
Notice something telling in that comparison? Windows already includes supported, non-destructive ways to purge several of the system paths Claude chose to attack with raw Remove-Item commands—including cleanmgr.exe for Delivery Optimization files, Thumbnails, and Windows Error Reporting, Delete-DeliveryOptimizationCache in PowerShell, and DISM /Online /Cleanup-Image /StartComponentCleanup for trimming superseded WinSxS components. Where the script genuinely adds reach is third-party app and developer caches.
Section Takeaway: The script's real value isn't that it cleans "nearly every inch" of a PC—a hardcoded list of known folders never does—but that it aggregates third-party browser, chat, media, and package-manager caches that Windows' built-in tools ignore.
Five Technical Flaws and Caveats to Fix Before Running It
If MakeUseOf's 4.8 GB result tempts you to copy the script straight into a terminal, hit pause. Inspecting the published code line by line turns up five issues ranging from a minor filename typo to flawed math and broken scheduled-task ergonomics.
1. Fix the .psl File Extension Typo
Near the end of the MakeUseOf guide, readers are told to save the script as a .psl file. That is a classic character-swap typo: Microsoft's about_Scripts documentation specifies that PowerShell script files use the .ps1 extension (number 1, not lowercase L). Saving it as .psl will prevent PowerShell from recognizing or running it as a script file.
2. -DryRun Measures Target Inventory, Not Deletable Space
In -DryRun mode, the script never tests file locks, permissions, or delete eligibility; it simply sums Length across every file found under $targets and C:\$Recycle.Bin. That means your dry-run estimate will almost always look rosier than reality, because active browser locks, protected system files, and SYSTEM-owned logs will throw exceptions and get silently skipped during a live run.
3. CleanupLog.txt Can Overstate How Much Space Was Freed
Look closely at the Recycle Bin section in live mode:
$bin = (Get-ChildItem 'C:\$Recycle.Bin' -File -Recurse -Force -ErrorAction SilentlyContinue |
Measure-Object Length -Sum).Sum
if ($null -eq $bin) { $bin = 0 }
$freed += [long]$bin
if (-not $DryRun) { Clear-RecycleBin -DriveLetter C -Force -ErrorAction SilentlyContinue }
The script adds the entire measured size of C:\$Recycle.Bin to $freed before calling Clear-RecycleBin—and then suppresses any errors from Clear-RecycleBin with -ErrorAction SilentlyContinue. As Microsoft's Clear-RecycleBin documentation notes, the cmdlet clears the current user's Recycle Bin contents, whereas C:\$Recycle.Bin holds subfolders for all user SIDs on the machine. If another profile owns gigabytes in C:\$Recycle.Bin, or if Clear-RecycleBin fails silently, CleanupLog.txt will still credit those bytes under LIVE (attempted). Measuring actual free volume space via Get-PSDrive C before and after the run would yield a far more honest number.
4. The Scheduled Task Isn't Truly Unattended
When run with -Schedule, the script registers a Task Scheduler job called WeeklyCleanup for Sundays at 10:00 using -LogonType Interactive -RunLevel Highest. That might sound automated—until you look at the finally block at the bottom of the script:
Read-Host "`nCleanup finished. Press Enter to close"
Because the scheduled task launches powershell.exe without -NonInteractive—which Microsoft's about_PowerShell_exe documentation recommends for scheduled tasks so that Read-Host fails cleanly rather than hanging—and uses an Interactive logon type, every Sunday cleanup will pop up and sit idle waiting for someone to press Enter. Worse, if the system is locked or unattended when the trigger fires, the session can stall indefinitely. Removing Read-Host (or gating it behind a -Pause switch) is mandatory before scheduling this script.
5. Wiping Update Caches and CBS Logs Has Diagnostic Costs
Not every megabyte in C:\Windows is "junk." Deleting C:\Windows\Logs\CBS wipes Component-Based Servicing history (CBS.log), which Microsoft Learn's troubleshooting guides specifically rely on to diagnose SFC, DISM, and Windows Update installation failures. Likewise, while clearing C:\Windows\SoftwareDistribution\Download with wuauserv stopped is a well-known repair trick when updates get stuck, Microsoft Q&A guidance notes that routinely deleting it forces Windows Update to rebuild datastore metadata and can slow subsequent update scans. And remember: clearing browser, Discord, Teams, Spotify, or pip/NuGet caches isn't permanent savings—every single one of those apps will re-download what it needs the next time you open it or build a project.
Section Takeaway: Treat Claude's output as a strong first draft, not finished production code. Fix the .ps1 extension, strip out Read-Host for scheduled runs, measure actual C: drive free space before and after cleanup, and think twice before auto-deleting CBS logs and SoftwareDistribution every Sunday.
How to Safely Use or Adapt This Approach on Windows 11
If you want the control of a transparent PowerShell script without the quirks in the published version, a disciplined workflow keeps your data—and your update history—safe:
- Audit Storage Sense and Disk Cleanup first: Open Settings > System > Storage > Storage Sense to confirm how often Windows is already running cleanup and whether Downloads or cloud-content thresholds are configured to your liking. Run
cleanmgr.exeas administrator once to clear superseded Windows Update and Delivery Optimization files using Microsoft's native handlers. - Trim the script's target list: Save the script with a
.ps1extension, then comment outC:\Windows\Logs\CBS,C:\Windows\SoftwareDistribution\Download, and any developer caches (npm-cache,pip,NuGet) you actively rely on offline. - Fix logging and unattended execution: Replace the pre-clear Recycle Bin math with a before-and-after check of
(Get-PSDrive C).Free, and removeRead-Hostfrom thefinallyblock before registering any scheduled task. - Test with
-DryRunand review the output: Run the script manually with-DryRunfirst to verify which folders actually hold meaningful bloat on your PC. A 4.8 GB swing on a cramped 256 GB drive is plausible if browser and media caches have piled up over months, but on a tidy system you may see far less. - Respect SSD headroom: As Khan rightly notes at the end of his piece, cleanup scripts only treat symptoms on an undersized boot drive. In general storage practice, keeping roughly 15% to 20% of an SSD free gives the controller room for garbage collection and SLC caching, and moving bulky media libraries or secondary apps onto another drive remains a cleaner long-term fix than weekly cache purges.
AI coding assistants like Claude have undeniably changed the math for Windows power users: you no longer need to install a nagging third-party cleaner just to sweep Chrome, Discord, and Spotify caches on a schedule. Just don't mistake "an AI wrote it in 10 seconds" for "ready for unattended admin privileges." Read every path, fix the interactive prompt and space-math bugs, and let Windows handle the system internals it already knows how to maintain.
References
- I replaced my PC cleanup apps with a PowerShell script Claude wrote, and it does more than any of them did - MakeUseOf MakeUseOf · 2026-12-03T16:00:17+00:00
- Clear-RecycleBin (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn learn.microsoft.com
- microsoft.com support.microsoft.com