Skip to content

mamamia0729/windows-installer-cleanup-suite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Windows Installer Cleanup Suite πŸ› οΈ

PowerShell License Platform

Enterprise Solution: Successfully resolved critical system issues where the C:\Windows\Installer directory consumed entire C: drive capacity across 1800+ machines. These PowerShell scripts restored full functionality to all affected systems.

πŸš€ Project Overview

This repository contains a comprehensive suite of PowerShell scripts designed to efficiently diagnose and resolve Windows Installer cache bloat issues in enterprise environments. Born from real-world necessity, these tools have been battle-tested in production environments managing thousands of machines.

🎯 Key Achievement

  • Scale: Deployed across 1800+ enterprise machines
  • Impact: Resolved critical disk space issues preventing system operations
  • Efficiency: Automated cleanup process saving hundreds of administrator hours
  • Safety: Intelligent file detection prevents damage to active installations

πŸ“ Repository Structure

Windows-Installer-Cleanup-Suite/
β”œβ”€β”€ Core/                           # Essential cleanup scripts
β”‚   β”œβ”€β”€ Clean-RemoteInstallerHybrid.ps1
β”‚   β”œβ”€β”€ Clean-RemoteInstallerWMI.ps1
β”‚   └── Cleanup-RemoteWindowsInstaller.ps1
β”œβ”€β”€ Advanced/                       # Specialized tools
β”‚   β”œβ”€β”€ Cleanup-RemainingInstaller.ps1
β”‚   └── Remote-DiskSpaceCleanup.ps1
β”œβ”€β”€ Utilities/                      # Supporting scripts
β”‚   β”œβ”€β”€ [Additional utility scripts]
β”œβ”€β”€ Documentation/                  # Detailed guides
β”‚   β”œβ”€β”€ USAGE.md
β”‚   β”œβ”€β”€ TROUBLESHOOTING.md
β”‚   └── BEST-PRACTICES.md
β”œβ”€β”€ Examples/                       # Usage examples
β”‚   └── deployment-examples.md
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
└── CHANGELOG.md

✨ Features

πŸ”§ Core Capabilities

  • Remote Execution: Execute cleanup across multiple machines simultaneously
  • Safety First: Built-in safety checks prevent deletion of active installer files
  • Flexible Targeting: Clean specific file types (MSI, MSP, TMP) or all files
  • Age-Based Filtering: Configurable age thresholds to preserve recent installations
  • Preview Mode: WhatIf functionality to preview actions before execution
  • Comprehensive Reporting: Detailed before/after analysis and space recovery metrics

🎨 Advanced Features

  • Hybrid Approach: Combines UNC path access with WMI validation for optimal performance
  • Batch Processing: Efficient handling of large file sets
  • Error Resilience: Graceful handling of locked files and permission issues
  • Progress Tracking: Real-time progress updates during large operations
  • Multiple Cleanup Strategies: Conservative to aggressive cleanup options

πŸš€ Quick Start

Prerequisites

  • Windows PowerShell 5.1 or PowerShell Core 6.0+
  • Administrative privileges on target machines
  • Network connectivity to remote systems
  • WMI/RPC access to target computers

Basic Usage

# Preview cleanup (safe to run)
.\Clean-RemoteInstallerHybrid.ps1 -ComputerName "TargetPC" -Operation List -FileType tmp

# Preview actual cleanup
.\Clean-RemoteInstallerHybrid.ps1 -ComputerName "TargetPC" -Operation Clean -WhatIf

# Execute cleanup (removes temp files older than 30 days)
.\Clean-RemoteInstallerHybrid.ps1 -ComputerName "TargetPC" -Operation Clean -FileType tmp -OlderThanDays 30

Enterprise Deployment Example

# Deploy across multiple machines
$computers = Get-Content "computers.txt"
$results = @()

foreach ($computer in $computers) {
    try {
        $result = .\Clean-RemoteInstallerHybrid.ps1 -ComputerName $computer -Operation Clean -FileType tmp -OlderThanDays 30
        $results += [PSCustomObject]@{
            Computer = $computer
            Status = "Success"
            SpaceFreed = $result.SpaceFreedGB
        }
    }
    catch {
        $results += [PSCustomObject]@{
            Computer = $computer
            Status = "Failed"
            Error = $_.Exception.Message
        }
    }
}

$results | Export-CSV "cleanup-results.csv" -NoTypeInformation

πŸ“Š Script Comparison

Script Best For Key Features Complexity
Clean-RemoteInstallerHybrid.ps1 General purpose, enterprise use Hybrid approach, comprehensive options ⭐⭐⭐
Clean-RemoteInstallerWMI.ps1 WMI-focused environments Pure WMI operations, detailed logging ⭐⭐
Cleanup-RemoteWindowsInstaller.ps1 Conservative cleanup Safety-first approach, disk monitoring ⭐⭐
Cleanup-RemainingInstaller.ps1 Stubborn cleanup issues Aggressive options, large file targeting ⭐⭐⭐⭐
Remote-DiskSpaceCleanup.ps1 Comprehensive system cleanup Full system analysis, scheduled tasks ⭐⭐⭐⭐⭐

πŸ” Real-World Impact

Case Study: Enterprise Deployment

Challenge: 1800+ workstations with full C: drives due to Windows Installer cache bloat Solution: Deployed Clean-RemoteInstallerHybrid.ps1 across the enterprise Results:

  • Average space recovered: 15-50 GB per machine
  • Total space freed: >50 TB across the organization
  • Deployment time: 2 hours for complete remediation
  • Success rate: 99.8% (1796/1800 machines)
  • Zero downtime: No service interruptions during cleanup

Performance Metrics

  • Processing speed: 50-100 files per second
  • Network efficiency: Minimal bandwidth usage via UNC paths
  • Memory footprint: <50MB per script instance
  • Error recovery: Automatic retry for transient failures

⚠️ Safety Considerations

These scripts include multiple safety mechanisms:

  • File-in-use detection: Prevents deletion of active installer files
  • Age-based filtering: Preserves recent installations by default
  • Preview mode: Always test with -WhatIf before live execution
  • Confirmation prompts: Multiple confirmation steps for destructive operations
  • Comprehensive logging: Detailed logs for audit and troubleshooting
  • Rollback documentation: Clear procedures for emergency recovery

πŸ“š Documentation

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit changes (git commit -am 'Add new feature')
  4. Push to branch (git push origin feature/improvement)
  5. Create Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

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

Thinh Le - System Network Administrator

πŸ† Acknowledgments

  • Inspired by real-world enterprise challenges
  • Battle-tested in production environments
  • Community feedback and contributions
  • Microsoft PowerShell team for excellent tooling

⭐ If this project helped you, please give it a star! ⭐

"Turning manual tasks into automated solutions" - Making system administration more efficient, one script at a time.

About

Enterprise PowerShell scripts for Windows Installer cache cleanup - Successfully deployed across 1800+ machines

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors