Skip to content

Latest commit

 

History

History
283 lines (207 loc) · 10.6 KB

File metadata and controls

283 lines (207 loc) · 10.6 KB

VMware Tools Auto-Upgrade PowerCLI Solution

PowerCLI VMware License Release Issues Stars

📋 Overview

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.

VMware Tools Auto-Upgrade Process

Enterprise PowerCLI solution for bulk VMware Tools auto-upgrade configuration

🎯 Key Features

  • 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

🚀 Quick Start

Prerequisites

  • 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)

Installation

# 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

📖 Usage Guide

Basic Usage

  1. Run in Dry-Run Mode (recommended first step):

    .\Enable-VMTools-AutoUpgrade-AllVMs.ps1
    # Select 'D' for dry-run when prompted
  2. Apply Changes (after validating dry-run results):

    .\Enable-VMTools-AutoUpgrade-AllVMs.ps1
    # Select 'A' for apply when prompted

Interactive Prompts

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

Sample Output

=== 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.

🔧 Technical Details

How It Works

  1. Discovery Phase: Scans all VMs in vCenter and collects current ToolsUpgradePolicy settings
  2. Analysis Phase: Identifies VMs that don't have auto-upgrade enabled
  3. Execution Phase: Uses ReconfigVM() API to set ToolsUpgradePolicy to "upgradeAtPowerCycle"
  4. Validation Phase: Verifies changes and provides before/after comparison

Configuration Changes

The script modifies only one VM property:

  • ToolsUpgradePolicy: Set to upgradeAtPowerCycle

All other VM configuration settings remain unchanged.

Safety Features

  • 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

📁 Repository Structure

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

🛡️ Security Considerations

Credentials Management

  • Use secure credential storage (Windows Credential Manager)
  • Implement least-privilege access principles
  • Consider using service accounts for automation

Network Security

  • Ensure secure connections to vCenter (HTTPS)
  • Validate SSL certificates in production environments
  • Use network segmentation for management traffic

Audit and Compliance

  • Log all operations for audit purposes
  • Implement change approval processes
  • Document all configuration changes

🔍 Troubleshooting

Common Issues

PowerCLI Not Loaded

# Solution: Import PowerCLI module
Import-Module VMware.PowerCLI

Connection Issues

# Check network connectivity
Test-NetConnection -ComputerName vcenter.example.com -Port 443

# Verify credentials
$cred = Get-Credential
Connect-VIServer -Server vcenter.example.com -Credential $cred

Permission Errors

  • Verify user has VM configuration privileges
  • Check vCenter permissions for ReconfigVM operations
  • Ensure user has access to all target VMs

Debug Mode

Enable verbose logging for troubleshooting:

$VerbosePreference = "Continue"
.\Enable-VMTools-AutoUpgrade-AllVMs.ps1

📊 Performance Considerations

Large Environments

  • 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

Optimization Tips

  • Run during maintenance windows for large environments
  • Consider filtering VMs by specific criteria if needed
  • Monitor vCenter performance during execution

🤝 Contributing

We welcome contributions to improve this solution:

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

Development Guidelines

  • Follow PowerShell best practices and style guidelines
  • Include comprehensive error handling
  • Add appropriate comments and documentation
  • Test thoroughly in lab environments before production use

📞 Support

📄 License

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

📚 Documentation

Quick Links

📊 Repository Statistics

  • 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)

📚 References


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.