Travis Quinnelly bio photo

Travis Quinnelly

vTechify is my home to talk about all things virtualization. Here I share things learned in lab and production environments both for my documentation and others to stumble upon for reference.

Twitter Google+ LinkedIn Instagram Github Last.fm
Check and upgrade Tools during power cycling

By default, many of us probably have our VMs check for new versions of VMTools upon each power cycle. That’s usually fine, but in some scenarios it’s not. Rather than change the global policy, this script will change just the VMs you want to not upgrade automatically.

Get-VM -Name <vmNamesHere> | Get-View | ForEach-Object {
  Write-Output $_.name
  if ($_.config.tools.toolsUpgradePolicy -ne "manual"){
    $vm = Get-VM -Name $_.name
    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $spec.tools = New-Object VMware.Vim.ToolsConfigInfo
    $spec.tools.toolsUpgradePolicy = "manual"
    $_this = Get-View -Id $vm.Id
    $_this.ReconfigVM_Task($spec)
    Write-Output "Completed"
  }
}