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.
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.
- 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
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
- 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:
WhatIffunctionality to preview actions before execution - Comprehensive Reporting: Detailed before/after analysis and space recovery metrics
- 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
- 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
# 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# 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 | 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 | βββββ |
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
- 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
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
-WhatIfbefore 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
- USAGE.md - Detailed usage instructions and parameters
- TROUBLESHOOTING.md - Common issues and solutions
- BEST-PRACTICES.md - Enterprise deployment guidelines
- CHANGELOG.md - Version history and updates
Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit changes (
git commit -am 'Add new feature') - Push to branch (
git push origin feature/improvement) - Create Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Thinh Le - System Network Administrator
- LinkedIn: Connect with me
- GitHub: @mamamia0729
- Expertise: PowerShell Automation, System Administration, Enterprise Solutions
- 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.