Skip to content

Ultimate Windows 11 maintenance script - automated updates, cleanup, and optimization in one command

License

Notifications You must be signed in to change notification settings

bivlked/WinClean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WinClean Logo

WinClean

Ultimate Windows 11 Maintenance Script

Version PSGallery CI PowerShell 7.1+ Windows 11 License: MIT

Automated system maintenance: updates, cleanup, and optimization in one script

English | Русский


Why WinClean? β€’ Features β€’ Quick Start β€’ Parameters β€’ Safety β€’ FAQ


🎯 Why WinClean?

😫 Before WinClean

  • Manually run Windows Update
  • Open each browser to clear cache
  • Remember npm/pip/nuget cache locations
  • Forget about Docker cleanup for months
  • Run Disk Cleanup separately
  • Hope you didn't delete something important

😎 With WinClean

  • One command does everything
  • All browsers cleaned automatically
  • All dev tools handled in parallel
  • Docker & WSL optimized
  • Deep cleanup with DISM
  • Safe by design β€” protected paths

πŸ’‘ Average cleanup result: 5-20 GB freed, depending on system usage


✨ Features

πŸ”„ Updates

  • Windows Update (+ drivers)
  • Microsoft Store apps
  • Winget packages
  • PSWindowsUpdate module

πŸ—‘οΈ Cleanup

  • Temp files (3 locations)
  • Browser caches (6 browsers)
  • Windows caches (8 types)
  • Recycle Bin emptying
  • Windows.old removal

πŸ‘¨β€πŸ’» Developer

  • npm / yarn / pnpm
  • pip / Composer
  • NuGet / Gradle / Cargo
  • Go build cache

🐳 Docker & WSL

  • Unused images
  • Stopped containers
  • Build cache
  • WSL2 VHDX compaction

πŸ› οΈ IDEs

  • Visual Studio caches
  • VS Code caches
  • JetBrains IDEs
  • MEF cache cleanup

πŸ”’ Privacy

  • DNS cache flush
  • Event logs cleanup
  • Run history (Win+R)
  • Explorer history
  • Recent documents
  • Telemetry (optional)

πŸš€ Quick Start

πŸ“¦ Install from PowerShell Gallery (Recommended)

Install-Script -Name WinClean -Scope CurrentUser

Then run as Administrator:

WinClean.ps1
πŸ“₯ Alternative installation methods

⚑ One-Line Download & Run

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`""

Manual Download

# Download
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/bivlked/WinClean/main/WinClean.ps1" -OutFile "WinClean.ps1"

# Run as Administrator
.\WinClean.ps1

Clone Repository

git clone https://github.com/bivlked/WinClean.git
cd WinClean
.\WinClean.ps1

πŸ“‹ Parameters

Parameter Description Default
-SkipUpdates Skip Windows and winget updates false
-SkipCleanup Skip all cleanup operations false
-SkipRestore Skip system restore point creation false
-SkipDevCleanup Skip developer caches (npm, pip, etc.) false
-SkipDockerCleanup Skip Docker/WSL cleanup false
-SkipVSCleanup Skip Visual Studio cleanup false
-DisableTelemetry Disable Windows telemetry via Group Policy false
-ReportOnly Dry run β€” show what would be done false
-LogPath Custom log file path Auto

πŸ’‘ Usage Examples

Full Maintenance

.\WinClean.ps1

All updates + all cleanup

Cleanup Only

.\WinClean.ps1 -SkipUpdates

No updates, just cleanup

Preview Mode

.\WinClean.ps1 -ReportOnly

See what would happen

Quick Clean

.\WinClean.ps1 -SkipUpdates -SkipDockerCleanup

Fast cleanup only


🎯 Recommended Profiles

Choose the right profile for your needs:

Profile Command Best For
Preview .\WinClean.ps1 -ReportOnly First run β€” see what will be cleaned without changes
Safe .\WinClean.ps1 -SkipUpdates -SkipDockerCleanup Minimal risk β€” only temp files and caches
Developer .\WinClean.ps1 Full cleanup β€” includes npm, pip, nuget, Docker, IDE caches
Quick .\WinClean.ps1 -SkipUpdates -SkipDevCleanup -SkipVSCleanup Fast β€” system cleanup only, no dev tools
Updates Only .\WinClean.ps1 -SkipCleanup Just Windows and app updates

πŸ’‘ Tip: Always run with -ReportOnly first to preview what will be cleaned!


πŸ”§ Requirements

Requirement Version Notes
Windows 11 Tested on 23H2/24H2/25H2
PowerShell 7.1+ Download here
Rights Administrator Required for system operations
πŸ“¦ Optional dependencies
Component Required For Auto-installed
PSWindowsUpdate Windows updates βœ… Yes
winget App updates ❌ Manual
Docker Desktop Docker cleanup ❌ Manual
WSL 2 WSL optimization ❌ Manual

πŸ›‘οΈ Safety

βœ… What WinClean Does

Safety Feature Description
πŸ”„ Restore Point Created before any changes
πŸ›‘οΈ Protected Paths System folders never touched
πŸ“¦ Preserves Packages NuGet, npm, Maven packages kept
❓ Confirmation Windows.old asks before deletion
πŸ”§ Service Recovery Uses try/finally for services
πŸ‘οΈ Preview Mode -ReportOnly shows changes first

🚫 Protected Paths (Never Deleted)

C:\Windows\
C:\Program Files\
C:\Program Files (x86)\
C:\Users\
C:\Users\YourName\

βœ… Safe to Clean vs πŸ›‘οΈ Preserved

βœ… Cleaned πŸ›‘οΈ Preserved
%TEMP%\* Documents, Downloads
Browser caches Browser bookmarks, passwords
npm-cache node_modules
pip\Cache Virtual environments
Composer\cache vendor
NuGet\v3-cache \.nuget\packages
\.gradle\build-cache \.gradle\caches\modules

πŸ“Š Execution Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     WinClean v2.13                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PREPARATION                                                   β”‚
β”‚  β”œβ”€ βœ“ Check Administrator Rights                               β”‚
β”‚  β”œβ”€ βœ“ Check Pending Reboot                                     β”‚
β”‚  └─ βœ“ Create System Restore Point                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  UPDATES                                                       β”‚
β”‚  β”œβ”€ πŸ”„ Windows Updates (including drivers)                     β”‚
β”‚  └─ πŸ”„ Winget Application Updates                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  CLEANUP                                                       β”‚
β”‚  β”œβ”€ πŸ—‘οΈ Temporary Files & Browser Caches                        β”‚
β”‚  β”œβ”€ πŸ—‘οΈ Developer Caches (npm, pip, nuget, gradle)              β”‚
β”‚  β”œβ”€ 🐳 Docker & WSL Optimization                               β”‚
β”‚  └─ πŸ› οΈ Visual Studio & IDE Caches                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  DEEP CLEANUP                                                  β”‚
β”‚  β”œβ”€ πŸ”§ DISM Component Cleanup                                  β”‚
β”‚  β”œβ”€ πŸ’Ύ Disk Cleanup (20+ categories)                           β”‚
β”‚  └─ πŸ“ Windows.old Removal (with confirmation)                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PRIVACY (optional)                                            β”‚
β”‚  β”œβ”€ πŸ”’ Clear DNS Cache & History                               β”‚
β”‚  └─ βš™οΈ Disable Telemetry (if -DisableTelemetry)                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ“Š SUMMARY REPORT                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Logging

Every run creates a detailed log:

%TEMP%\WinClean_20260117_143052.log

Log contents:

  • ⏰ Timestamp for each operation
  • βœ… Success / ⚠️ Warning / ❌ Error status
  • πŸ“Š Freed space per category
  • ⏱️ Total execution time

❓ FAQ

Is it safe to run WinClean?

Yes! WinClean creates a restore point before making changes and never touches protected system paths. Use -ReportOnly to preview changes first.

Will it delete my installed programs?

No. WinClean only cleans caches and temporary files. Your installed programs, npm packages, NuGet packages, and user data remain untouched.

How often should I run it?

Monthly is recommended. Heavy developers or users with limited disk space may benefit from weekly runs.

Why does it need Administrator rights?

Required for: Windows Update, system cache cleanup, DISM operations, service management, and creating restore points.

Can I run it on Windows 10?

Primarily designed for Windows 11, but most features work on Windows 10 with PowerShell 7.1+.

What if something goes wrong?

Use the restore point created at the start to roll back. Check the log file for details about what was changed.


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


⭐ Star this repo if you find it useful!

Report Bug β€’ Request Feature β€’ Changelog

Made with ❀️ for Windows users