Skip to content

Enterprise PowerCLI solution for bulk-enabling VMware Tools auto-upgrade on power-on across all VMs in vCenter environments. Features dry-run mode, comprehensive reporting, and enterprise-grade security.

License

Notifications You must be signed in to change notification settings

uldyssian-sh/vmware-tools-auto-upgrade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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.

About

Enterprise PowerCLI solution for bulk-enabling VMware Tools auto-upgrade on power-on across all VMs in vCenter environments. Features dry-run mode, comprehensive reporting, and enterprise-grade security.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •