Releases: bivlked/WinClean
v2.13 - Statistics Accuracy & Pester Tests
🎯 What's New in v2.13
This release focuses on statistics accuracy and introduces comprehensive Pester testing for CI/CD.
🐛 Fixed
- Docker statistics parsing: Fixed regex to support both
reclaimed XandTotal reclaimed space: Xoutput formats - Event logs WarningsCount: Fixed missing counter increment when event log clearing fails
- Windows Update false success: Added null-check to prevent misleading "0 updates installed" messages
- Temp files deduplication: Fixed duplicate cleanup when
%TEMP%equals%LOCALAPPDATA%\Temp - Browser cache negative values: Prevented incorrect statistics when browser recreates files during cleanup
⚡ Improved
- Get-FolderSize performance: Added
-Fileflag to skip directory objects (significantly faster) - Docker cleanup efficiency: Removed redundant
docker builder prune(already included in system prune) - Recycle Bin size fallback: Added
GetDetailsOffallback for more reliable size calculation - Disk Cleanup registry cleanup: StateFlags9999 now properly removed after cleanmgr execution
🧪 New: Pester Tests
- Added
tests/Helpers.Tests.ps1with 52 unit tests for helper functions - Added
tests/Fixes.Tests.ps1with 42 validation tests for all v2.13 fixes - Updated CI/CD workflow with Pester test job
- 94 tests passing ✅
📦 Installation
From PowerShell Gallery (Recommended)
Install-Script -Name WinCleanUpdate existing installation
Update-Script -Name WinCleanDirect download
irm https://raw.githubusercontent.com/bivlked/WinClean/main/WinClean.ps1 -OutFile WinClean.ps1🚀 Quick Start
# Preview mode (no changes)
.\WinClean.ps1 -ReportOnly
# Full maintenance
.\WinClean.ps1
# Skip updates, only cleanup
.\WinClean.ps1 -SkipUpdatesFull Changelog: https://github.com/bivlked/WinClean/blob/main/CHANGELOG.md
WinClean v2.9 - PSWindowsUpdate Reliability
🚀 WinClean v2.9 - PSWindowsUpdate Installation Reliability
This release fixes a critical issue where the script could hang indefinitely when installing the PSWindowsUpdate module.
Problem
The script would freeze at "Installing PSWindowsUpdate module..." and never progress. This happened because:
- Missing TLS 1.2 - PowerShell Gallery requires TLS 1.2, but older Windows configurations may default to TLS 1.0/1.1
- No timeout -
Install-Modulehas no built-in timeout and waits indefinitely on network issues - No availability check - The script checked general internet connectivity but not specifically PowerShell Gallery
Solution
| Component | Implementation |
|---|---|
| TLS 1.2 | Enforced at script start via [Net.ServicePointManager]::SecurityProtocol |
| PSGallery Check | New Test-PSGalleryConnection function (10s timeout) |
| Module Install | New Install-ModuleWithTimeout function (120s timeout) |
| NuGet Provider | New Install-PackageProviderWithTimeout function (60s timeout) |
| Error Handling | Clear messages with manual installation instructions |
New Behavior
[03:02:17] [INFO] Checking PowerShell Gallery availability...
[03:02:18] [INFO] Installing PSWindowsUpdate module...
[03:02:45] [OK] PSWindowsUpdate installed
If installation fails or times out:
[03:02:17] [INFO] Checking PowerShell Gallery availability...
[03:04:17] [ERROR] Module installation timed out after 120 seconds
[03:04:17] [ERROR] Failed to install PSWindowsUpdate - Windows Update skipped
[03:04:17] [INFO] Try manual installation: Install-Module PSWindowsUpdate -Force -Scope CurrentUser
Upgrade Notes
Drop-in replacement - no configuration changes needed. The script will now:
- Complete or fail within reasonable timeouts (no more indefinite hangs)
- Provide clear error messages if PSGallery is unavailable
- Continue with other maintenance tasks even if Windows Update setup fails
Full Changelog: https://github.com/bivlked/WinClean/blob/main/CHANGELOG.md
Previous Release: v2.8
WinClean v2.8 - Disk Cleanup Reliability
🚀 Disk Cleanup Reliability Improvements
This release significantly improves the reliability of the Disk Cleanup stage, which could previously hang for extended periods even after cleanup completed.
Fixed 🔧
Disk Cleanup hanging issue
- Reduced timeout from 10 minutes to 7 minutes for faster completion
- Replaced
-NoNewWindowwith-WindowStyle Hiddenfor more reliable window handling - Replaced
Wait-Processwith explicitHasExitedloop for better process control - Added progress logging every minute for visibility
Changes Summary
| Setting | Before | After |
|---|---|---|
| Timeout | 10 minutes | 7 minutes |
| Window style | -NoNewWindow |
-WindowStyle Hidden |
| Wait method | Wait-Process |
Explicit HasExited loop |
| Progress feedback | None | Logs every 60 seconds |
New Behavior
[13:00:57] [INFO] Storage Sense task not found, using Disk Cleanup...
[13:01:57] [INFO] Disk Cleanup still running... (60 seconds)
[13:02:57] [INFO] Disk Cleanup still running... (120 seconds)
[13:03:15] [OK] Disk Cleanup completed
What was the problem?
In previous versions, the script could wait up to 10 minutes for cleanmgr.exe even after the Disk Cleanup window had visually completed. This was due to:
- The
-NoNewWindowparameter causing issues with process completion detection Wait-Processnot reliably detecting when cleanmgr.exe finished- Overly long timeout that delayed script completion
Full Changelog: https://github.com/bivlked/WinClean/blob/main/CHANGELOG.md
Previous Release: v2.7
v2.7 - Consistent Cyan Frame
UI Fix
Fixed
- Header frame color: Top border (╔═╗) and side borders (║) of header now use Cyan like the rest of the frame
Visual Result
╔══════════════════════════════════════════════════════════════════════╗ <- Cyan
║ COMPLETED SUCCESSFULLY ║ <- Cyan frame, Green text
╠══════════════════════════════════════════════════════════════════════╣ <- Cyan
║ > Duration: 00:06:24 ║
...
╚══════════════════════════════════════════════════════════════════════╝ <- Cyan
The status text (COMPLETED SUCCESSFULLY / WITH WARNINGS / WITH ERRORS) remains colored (Green/Yellow/Red) to indicate completion status.
Full Changelog: v2.6...v2.7
v2.6 - Final Statistics Frame Polish
UI Improvements
Fixed
- Frame color consistency: All parts of the final statistics frame now use consistent Cyan color
- The separator line between main stats and categories was DarkGray — now Cyan
- Label/value spacing: Added 2-space gap between label and value columns
- Before:
Updates installed:Windows: 0, Apps: 3(merged) - After:
Updates installed: Windows: 0, Apps: 3(clear separation)
- Before:
- Category alignment: Category names (Temp, System, etc.) now right-aligned
- Colons in category names align with colons in main labels like "Updates installed:"
Visual Result
╔══════════════════════════════════════════════════════════════════════╗
║ COMPLETED SUCCESSFULLY ║
╠══════════════════════════════════════════════════════════════════════╣
║ > Duration: 00:07:42 ║
║ ↑ Updates installed: Windows: 0, Apps: 3 ║
║ > Space freed: 196,87 MB ║
╟──────────────────────────────────────────────────────────────────────╢
║ Temp: 187,92 MB ║
║ System: 8,94 MB ║
╠══════════════════════════════════════════════════════════════════════╣
║ > Disk space: 389.93 GB / 1862.07 GB (20.9% free) ║
╚══════════════════════════════════════════════════════════════════════╝
Full Changelog: v2.5...v2.6
v2.5 - UI Alignment Fixes
UI Fixes
Fixed
- Subsection lines width: Gray subsection lines (
└────) now extend to match TITLE frame width (70 characters instead of 67) - Final statistics alignment: Replaced emoji icons (⏱🗑💾) with ASCII characters (
>) to fix border misalignment - Width formula: Corrected Write-StatLine width calculation formula for proper value padding
Technical Details
Emoji characters (like ⏱🗑💾) occupy 2 visual positions in terminal output, but PowerShell's String.Length counts them as 1 character. This caused the right border (║) to misalign. Fixed by replacing emoji with ASCII characters that occupy exactly 1 position.
Full Changelog: v2.4...v2.5
WinClean v2.4 - UI Improvements
Visual & UX Improvements
This release focuses on improving the visual consistency and user experience of the script output.
What's New
1. Consistent Left Indent
All output now has a 2-space left margin, matching the banner style:
[11:10:49] [OK] Restore point created: WinClean 2026-01-16 11:10
╔══════════════════════════════════════════════════════════════════════╗
║ WINDOWS UPDATE ║
╚══════════════════════════════════════════════════════════════════════╝
2. Full Frame for Major Sections
Major sections (WINDOWS UPDATE, SYSTEM CLEANUP, etc.) now have full box frames instead of just two horizontal lines:
Before:
═══════════════════════════════════════════════════════════════════
WINDOWS UPDATE
═══════════════════════════════════════════════════════════════════
After:
╔══════════════════════════════════════════════════════════════════════╗
║ WINDOWS UPDATE ║
╚══════════════════════════════════════════════════════════════════════╝
3. Preserved Subsection Style
The original subsection style is kept as requested:
┌─ Driver Updates
└─────────────────────────────────────────────────────────────────
4. Enhanced Final Statistics
- Status-dependent header color: Green (success), Yellow (warnings), Red (errors)
- Status icons for each metric
- Smart highlighting: Space freed >1GB = Green, >100MB = Yellow
- Disk space warnings: <10% = Red, <20% = Yellow
5. No More Auto-Close
The 60-second auto-close timeout has been removed. The window now waits indefinitely for a keypress, so you won't miss results if distracted during long operations.
Full Changelog: https://github.com/bivlked/WinClean/blob/main/CHANGELOG.md
WinClean v2.3 - Critical Bug Fix
Critical Bug Fix
The Problem
"Space freed" always showed 0 bytes in the final statistics window, regardless of how much disk space was actually cleaned.
Users saw:
╔══════════════════════════════════════════════════════════════════════╗
║ Duration: 00:05:23 ║
║ Space freed: 0 Bytes ← Always zero! ║
╚══════════════════════════════════════════════════════════════════════╝
Root Cause
The code used [System.Threading.Interlocked]::Add([ref]$script:Stats.TotalFreedBytes, $freed) to update the counter.
Problem: In PowerShell, [ref] doesn't work with hashtable elements! It creates a temporary copy of the value instead of a reference to the hashtable slot. Interlocked.Add modified this temporary value, which was then discarded.
# This DOESN'T work in PowerShell:
[System.Threading.Interlocked]::Add([ref]$hashtable.Key, $value)
# The $hashtable.Key remains unchanged!The Fix
Replaced all 6 occurrences with simple += operator:
# Before (broken):
[System.Threading.Interlocked]::Add([ref]$script:Stats.TotalFreedBytes, $freed) | Out-Null
# After (works):
$script:Stats.TotalFreedBytes += $freedThe synchronized hashtable already provides thread-safety for basic operations.
Impact
- Affected versions: 2.0, 2.1, 2.2
- Symptoms: "Space freed: 0 Bytes" in final statistics
- Actual cleanup: Was working correctly, only the counter was broken
Upgrade
Replace your existing WinClean.ps1 with the new version. No configuration changes needed.
Full Changelog: https://github.com/bivlked/WinClean/blob/main/CHANGELOG.md
WinClean v2.2 - First Stable Release
WinClean v2.2
First Stable Release
Ultimate Windows 11 maintenance script - automated updates, cleanup, and optimization in one command
Highlights
This is the first stable release of WinClean after extensive testing and bug fixes. The script is now production-ready for Windows 11 systems.
What WinClean Does
- Updates: Windows Update, Microsoft Store, Winget packages
- Cleanup: Temp files, browser caches, Windows caches, Recycle Bin
- Developer: npm, pip, NuGet, Gradle, Cargo, Go, Composer caches
- Docker & WSL: Unused images, stopped containers, VHDX compaction
- IDEs: Visual Studio, VS Code, JetBrains caches
- Privacy: DNS cache, Run history, Explorer history, Event logs
Average Result: 5-20 GB freed
Installation
One-Line Install & Run
```powershell
irm https://raw.githubusercontent.com/bivlked/WinClean/main/WinClean.ps1 -OutFile "$env:TEMP\WinClean.ps1"; Start-Process pwsh -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$env:TEMP\WinClean.ps1`""
```
Requirements
| Requirement | Version |
|---|---|
| Windows | 11 (23H2/24H2/25H2) |
| PowerShell | 7.1+ |
| Rights | Administrator |
What's New in v2.2
Fixed
- TcpClient resource leak: Now properly closed in
finallyblock to prevent socket exhaustion - Code region markers: Fixed 8 misplaced
#regiontags for proper IDE folding - Banner ASCII art: Changed from "DREAM" to "CLEAN" to match script name
Documentation
- Added new SVG logo
- Added Recycle Bin and Event logs to Features section
- Full sync between English and Russian README
Version History
See CHANGELOG.md for complete version history.
Safety Features
| Feature | Description |
|---|---|
| Restore Point | Created before any changes |
| Protected Paths | System folders never touched |
| Preview Mode | -ReportOnly shows changes first |
| Confirmation | Windows.old asks before deletion |
Quick Usage
| Command | Description |
|---|---|
.\WinClean.ps1 |
Full maintenance |
.\WinClean.ps1 -SkipUpdates |
Cleanup only |
.\WinClean.ps1 -ReportOnly |
Preview mode |
Thank you for using WinClean!
Documentation · Report Bug · Request Feature
Made with love for Windows users