Repository navigation
2.0 Windows Cache Cleaner & Update/Optimize 馃Ч
This PowerShell script is designed to automate various system maintenance tasks on Windows. It performs the following operations:
-
Check Administrator Privileges: Checks if the script is being run with administrative privileges. If not, it restarts the script with elevated privileges.
-
Install Required Module: Installs the
PSWindowsUpdatemodule if not already installed. -
Disk Optimization: Optimizes the C drive by defragmenting, retrimming, consolidating slabs, and optimizing tiers.
-
File Cleanup:
- Cleans up specified directories, including
C:\Windows\Prefetch,C:\Windows\SoftwareDistribution, temporary directories, and printer spooler directory. - Counts the number of files deleted during cleanup.
- Cleans up specified directories, including
-
Event Log Cleanup: Clears the Windows event logs.
-
Disk Cleanup (cleanmgr): Initiates the disk cleanup process in the background using
cleanmgrwith very low disk space and automatic cleanup options. -
Application Update (Optional):
- Asks the user if they want to update applications.
- Checks for the presence of the
wingetpackage manager. If installed, it upgrades all applications. - If
wingetis not installed, prompts the user to install it.
-
Windows Update (Optional):
- Asks the user if they want to update Windows Update.
- Installs available Windows updates from Microsoft Update and accepts all updates without a reboot.
How to Use
-
Right click and run the script.
-
Accept elevate permissions
-
Follow the on-screen prompts to proceed with various maintenance tasks.
Requirements
- Windows PowerShell 5.1 or higher
- Administrative privileges
PSWindowsUpdatemodule (automatically installed by the script if not present)wingetpackage manager (optional, for application updates)
Notes
- Ensure that you have a backup of important data before running any maintenance script.
- Review the script and customize it according to your specific requirements before execution.
Author
This script was authored by Ikkxeer
For any inquiries or issues, please contact @ikkxeer
Contributing
Contributions to enhance the script or address issues are welcome. Please open a GitHub issue or submit a pull request.
Full Changelog: 1.0...2.0