This PowerCLI solution provides enterprise-grade automation for bulk-enabling VMware Tools auto-upgrade on power-on across all virtual machines in a vCenter environment. The script implements a safe, controlled approach with dry-run capabilities and comprehensive before/after reporting.
Latest Update: Repository now includes comprehensive monitoring, batch execution, and enterprise-grade CI/CD pipeline.
Enterprise PowerCLI solution for bulk VMware Tools auto-upgrade configuration
- Bulk Operations: Process all VMs in vCenter simultaneously
- Safe Execution: Dry-run mode for validation before applying changes
- Minimal Impact: Changes only the ToolsUpgradePolicy, leaving other VM configurations untouched
- Comprehensive Reporting: Before/after state comparison with detailed diff analysis
- Error Handling: Robust error handling with detailed logging
- Enterprise Ready: Suitable for production environments with thousands of VMs
- PowerCLI: VMware PowerCLI module installed and loaded
- vCenter Access: Administrative privileges on target vCenter Server
- PowerShell: PowerShell 5.1 or later (Windows PowerShell or PowerShell Core)
# Clone the repository
git clone https://github.com/uldyssian-sh/vmware-tools-auto-upgrade.git
cd vmware-tools-auto-upgrade
# Install required PowerShell modules
.\requirements.psd1 # Run the installation script
# Configure execution policy (if needed)
.\scripts\Set-ExecutionPolicy-Helper.ps1
# Run the script
.\scripts\Enable-VMTools-AutoUpgrade-AllVMs.ps1-
Run in Dry-Run Mode (recommended first step):
.\Enable-VMTools-AutoUpgrade-AllVMs.ps1 # Select 'D' for dry-run when prompted
-
Apply Changes (after validating dry-run results):
.\Enable-VMTools-AutoUpgrade-AllVMs.ps1 # Select 'A' for apply when prompted
The script will prompt for:
- vCenter Server: FQDN or IP address of your vCenter Server
- Credentials: vCenter administrator credentials
- Execution Mode: Dry-run (D) or Apply (A)
- Confirmation: Final confirmation before applying changes
=== VMware Tools Auto-Upgrade on Power-On (ALL VMs) ===
Enter vCenter FQDN or IP: vcenter.example.com
Mode: (D)ry-run or (A)pply [D/A]: D
DRY-RUN mode. No changes will be made.
=== BEFORE (All VMs) ===
VMName PowerState ToolsUpgradePolicy
------ ---------- ------------------
VM-001 PoweredOn manual
VM-002 PoweredOff upgradeAtPowerCycle
VM-003 PoweredOn
VMs that do NOT have auto-upgrade enabled (candidates):
VMName PowerState ToolsUpgradePolicy
------ ---------- ------------------
VM-001 PoweredOn manual
VM-003 PoweredOn
Total candidates: 2
DRY-RUN complete. No changes performed.
- Discovery Phase: Scans all VMs in vCenter and collects current ToolsUpgradePolicy settings
- Analysis Phase: Identifies VMs that don't have auto-upgrade enabled
- Execution Phase: Uses ReconfigVM() API to set ToolsUpgradePolicy to "upgradeAtPowerCycle"
- Validation Phase: Verifies changes and provides before/after comparison
The script modifies only one VM property:
- ToolsUpgradePolicy: Set to
upgradeAtPowerCycle
All other VM configuration settings remain unchanged.
- Dry-Run Mode: Preview changes without applying them
- Confirmation Prompts: Multiple confirmation steps before applying changes
- Error Handling: Graceful error handling with detailed error messages
- State Validation: Before/after state comparison to verify successful changes
vmware-tools-auto-upgrade/
βββ .github/
β βββ workflows/
β β βββ ci.yml # CI/CD pipeline
β βββ dependabot.yml # Dependency updates
βββ assets/
β βββ images/ # Documentation images
βββ docs/
β βββ USAGE.md # Detailed usage guide
β βββ TROUBLESHOOTING.md # Troubleshooting guide
β βββ API-REFERENCE.md # Complete API reference
βββ examples/
β βββ sample-output.txt # Example script output
β βββ batch-execution.ps1 # Enterprise batch execution
βββ scripts/
β βββ Enable-VMTools-AutoUpgrade-AllVMs.ps1 # Main script
βββ tests/
β βββ Test-VMToolsUpgrade.ps1 # Comprehensive test suite
βββ CHANGELOG.md # Version history
βββ CONTRIBUTING.md # Contribution guidelines
βββ LICENSE # MIT license
βββ README.md # This file
βββ SECURITY.md # Security policy
- Use secure credential storage (Windows Credential Manager)
- Implement least-privilege access principles
- Consider using service accounts for automation
- Ensure secure connections to vCenter (HTTPS)
- Validate SSL certificates in production environments
- Use network segmentation for management traffic
- Log all operations for audit purposes
- Implement change approval processes
- Document all configuration changes
# Solution: Import PowerCLI module
Import-Module VMware.PowerCLI# Check network connectivity
Test-NetConnection -ComputerName vcenter.example.com -Port 443
# Verify credentials
$cred = Get-Credential
Connect-VIServer -Server vcenter.example.com -Credential $cred- Verify user has VM configuration privileges
- Check vCenter permissions for ReconfigVM operations
- Ensure user has access to all target VMs
Enable verbose logging for troubleshooting:
$VerbosePreference = "Continue"
.\Enable-VMTools-AutoUpgrade-AllVMs.ps1- Batch Processing: Script processes VMs sequentially to avoid overwhelming vCenter
- Resource Usage: Minimal impact on vCenter resources
- Execution Time: Approximately 1-2 seconds per VM for configuration changes
- Run during maintenance windows for large environments
- Consider filtering VMs by specific criteria if needed
- Monitor vCenter performance during execution
We welcome contributions to improve this solution:
- Fork the repository
- Create a feature branch (
git checkout -b feature/enhancement) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/enhancement) - Create a Pull Request
- Follow PowerShell best practices and style guidelines
- Include comprehensive error handling
- Add appropriate comments and documentation
- Test thoroughly in lab environments before production use
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
This project is licensed under the MIT License - see the LICENSE file for details.
- Usage Guide - Comprehensive usage instructions and examples
- API Reference - Complete parameter and function documentation
- Troubleshooting Guide - Common issues and solutions
- Contributing Guidelines - How to contribute to the project
- Security Policy - Security guidelines and vulnerability reporting
- Changelog - Version history and release notes
- Sample Output - Example script execution output
- Batch Execution - Enterprise batch processing example
- Test Suite - Comprehensive testing framework
- Total Scripts: 8 PowerShell scripts
- Documentation Files: 12 comprehensive guides
- Test Coverage: Unit, Integration, and Performance tests
- Security Features: Hardening, Compliance, and Audit logging
- Enterprise Features: Deployment, Monitoring, and Batch processing
- Supported Environments: Small (10-100 VMs) to Enterprise (5000+ VMs)
- VMware vSphere API Reference Documentation
- PowerCLI Cmdlet Reference Guide
- VMware Tools Installation and Configuration Guide
- vSphere Security Best Practices Documentation
Maintained by: uldyssian-sh
β Star this repository if you find it helpful!
Disclaimer: Use of this code is at your own risk. Author bears no responsibility for any damages caused by the code.
