Mass Toggle of vmtools Auto Update Settings

Posted: November 28, 2012 in Scripts, VMware

While I like having VMs update their tools on reboot, it can cause some issues with running SRM testing and planned migrations, causing timeouts while waiting for vmtools. Rather than increase the timeout or go through the hassle of raising a change to updated the tools across an environment, I used the following script block to disable auto update for all the VMs and re-enable it once it came across to the other side. All credit goes to Damian Karlson for this one. Just reposting so I have my own copy.

# Get all the VMs
$VMs = Get-VM

# Loop it through
ForEach ($vm in $VMs){
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.changeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.tools = New-Object VMware.Vim.ToolsConfigInfo
# Disable the auto update
$spec.tools.toolsUpgradePolicy = "manual"
$_this = Get-View -Id $vm.Id
$_this.ReconfigVM_Task($spec)
}

To re-enable:
$spec.tools.toolsUpgradePolicy = "upgradeAtPowerCycle"

Thanks Damian!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s