PowerCLI VMtools Update on Reboot

Easy task for today was to set all the virtual machines to auto update the VMware tools on next reboot, we could of course manually use the webclient on each virtual machine but that is a bit time consuming, so we may as well use some PowerCLI to get the job done.

Here is some quick code to do the job.

1
2
3
4
5
6
7
Foreach ($VMS in (Get-VM)) {
$VM = $VMS | Get-View
$VMConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$VMConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$VMConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$VM.ReconfigVM($vmConfigSpec)
}

 

 

 

 

1 Comment

  1. Uday Singh

    Saved me some time ! Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *