troubleshooting Question

Update VMware Tools on Windows at powercycle in Powershell

Avatar of jmachado81
jmachado81 asked on
Powershell* PowerCLIWindows OSVMware
4 Comments1 Solution93 ViewsLast Modified:
Is there a way to change all windows VMs to upgrade VMware Tools at power cycle?  This is a great site that shows how to change it for ALL VMs, but i just want to do the Windows from guestID or guestFamily.  We have alot of appliances and non-windows systems where the guest manages the tools.

http://www.baylyparker.com/2017/01/powercli-script-for-time-vmtools/ 

#Auto Update VMware Tools on power cycle on an individual VM
$VM = Get-VM $VMName | Get-View
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$VM.ReconfigVM($vmConfigSpec)
======================================================================
#Auto Update VMware Tools on power cycle for ALL VMs
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
Get-View -ViewType VirtualMachine | % {$_.ReconfigVM($vmConfigSpec) }

#or
Foreach ($v in (get-vm)) {
$vm = $v | Get-View
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$vm.ReconfigVM($vmConfigSpec)
}
=======================================================================
#To get the current policy
Get-View -ViewType virtualmachine | select name,@{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy } }
=======================================================================
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros