I can't execute PowerShell in the environment this script was written in, so none of the boxes below are pre-checked — this is a manual checklist for you to work through on a real Windows machine before treating the script as release-ready.
-
Normal user (non-admin) Run without elevation. Confirm Windows Temp and Prefetch/Windows Update Cache (if enabled) are correctly reported as "Skipped (Administrator required)", while User Temp and Recent Items still clean normally.
-
Administrator Run elevated (Run as Administrator). Confirm Windows Temp, Prefetch, and Windows Update Cache all attempt cleanup instead of being skipped.
-
Empty Temp folder Manually empty
%TEMP%first, then run. Confirm it reports 0 found, 0 deleted, 100% cleaned, and "Cleaned successfully." -
Locked files present Open a file from Temp in another program (e.g. open a log file in Notepad) so it can't be deleted, then run. Confirm: - That one file is skipped, not the whole folder -
Remainingreflects the locked file -Errorsand the exception-type breakdown show up correctly - The rest of the folder still gets cleaned -
Missing folder Point
-FolderPathat a path that doesn't exist (temporarily edit the script or test in isolation) and confirm "Folder Status : Not Found" andStatus = "Folder Not Found"without throwing an unhandled error. -
Verbose mode Run with
-VerboseOutputand confirm per-itemDeleted :/Skipped :lines appear during cleanup. -
Auto mode Run with
-Auto(and separately-SkipPrompt) and confirm the Y/N prompt is skipped and cleanup starts immediately. -
Log generation After a run, confirm a new
cleanup-yyyy-MM-dd-HH-mm.txtfile is created next to the script, contains the full report (per-location detail, summary, error breakdown if any, footer), and that previous runs' log files are still present (not overwritten).
- -IncludePrefetch — run elevated, confirm Prefetch is cleaned and skipped correctly when not elevated.
- -IncludeRecent — confirm Recent Items cleans without requiring admin.
- -IncludeWindowsUpdateCache — run elevated; note that some files may be
locked by the Windows Update service unless
wuauservis stopped first. - -IncludeRecycleBin — confirm the Recycle Bin empties, and that the script degrades gracefully (reports a skipped/failed status rather than crashing) if the Recycle Bin COM object is unavailable in a given environment.
- Files Deleted + Folders Deleted matches the console/log "Deleted" count for each location.
- Total Size Freed looks plausible against actual disk space freed (spot-check with folder Properties before/after).
- Overall Status shows
SUCCESSonly when remaining = 0 and errors = 0 across all cleaned locations; otherwiseCOMPLETED WITH WARNINGS.
-
.\TempCleaner.ps1 -Versionprints version info and exits without cleaning. -
.\TempCleaner.ps1 -?orGet-Help .\TempCleaner.ps1 -Fullshows the comment-based help correctly (Synopsis, Description, all Parameters, Examples).
- Recycle Bin
SizeFreedis always reported as 0 (documented limitation, not a bug) — confirm this is acceptable or flag if you want it addressed. - Script has not been tested against PowerShell 7 specifically — only written against Windows PowerShell 5.1 conventions. Worth a pass if you run PS7 regularly.