VMware Cloud Community
jessem
Enthusiast
Enthusiast

Multiple VMs policy for vmware tools - Check and upgrade Tools during power cycle

Hello,

I need some help to know how to script/PowerCLI the Advanced option in Edit Settings for VMs to "Check and upgrade Tools during power cycling" on multiple VMs.

With that being said, can you run the command against a subset of VMs like ones in a particular cluster, or ones in a VM folder under VMs and Templates view?

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Reply
0 Kudos
jmneff
Contributor
Contributor

The link that LucD provided shows the way to do it.  Here's a function that I have added to scripts to do it.  You can just loop through a list of VM names and pass them into the function.

Function Enable-VMtoolsUpgrade($vm){

    Write-Host "Configuring VMTools upgrade setting"

    $vmview = Get-vm $vm | Get-View

    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    $vmConfigSpec.tools = New-Object VMware.Vim.ToolsConfigInfo

    $vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"

    $vmConfigSpec.Tools.syncTimeWithHost = $true

    $vmview.ReconfigVM_task($vmConfigSpec) | Out-Null

}

Reply
0 Kudos