What is the best method for enabling this option on all VMs? Is there a good way to do it without either editing the VMX files on every machine or doing it manually though edit settings?
Yes, it should.
Does it not work for you ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
fantastic tip!
thanks dhenry
LucD/All,
Background: Running ESXi 5.5U1 on 30 hosts and 550+ VMs. Maintaining current tools version is next to impossible manually.
Hoping there is a way to make this work. Based off of LucD's script this is what I am currently using:
#Connect to vCenter
$vCenter = Read-Host "Which vCenter do you want to connect to?"
Connect-VIServer $vCenter
#Create variable
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
#Execute change for all VMs excluding templates
Get-View -ViewType VirtualMachine | %{
$_.ReconfigVM($vmConfigSpec)
}
However, I want to see if there is a way to specify custom installation options with this option as we do not want to install vShield Drivers, Shared Folders, etc. Hoping someone catches this response since the thread has been idle for some time. Thanks for any information you can provide!
Andreas has a good post on that. See An analysis of the vSphere 5.5 VMware Tools for Windows installation
You could script the running of the setup.exe via Invoke-VMScript, or you could update the bat files with your own version, and then use the method I mentioned earlier.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD and everyone!
How can i write script to change vmtools of its upgrade policy during powercycle and only ist of servers on a notepad that i keep on a particular path?
Thanks
Sorry the question is not clear to me.
Perhaps you can elaborate a bit more, and eventually show with some screenshots what you want to achieve ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
i would like the script to call for list of servers that i put on a notepad in a certain path.
Only this list of servers then only i would want it to edit the upgrade policy to upgrade during powercycle.
Could you please help?
Hi Luc,
managed to write the powershell like i want like in following,
$vCname = Read-Host “Enter the vCenter or ESXi host name to connect”
if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
Add-PSSnapin VMware.VimAutomation.Core
}
Connect-viserver $vcname
$VirtualMachines = Get-Content "upgrade_vmware.txt"
foreach ($vm in (Get-VM -Name $VirtualMachines)){
if($vm.config.Tools.ToolsUpgradePolicy -ne "UpgradeAtPowerCycle") {
$config = New-Object VMware.Vim.VirtualMachineConfigSpec
$config.ChangeVersion = $vm.ExtensionData.Config.ChangeVersion
$config.Tools = New-Object VMware.Vim.ToolsConfigInfo
$config.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$vm.ExtensionData.ReconfigVM($config)
Write-Host "Update Tools Policy on $vm completed"
}
}
Thanks!
Hello !
Thank you for this script.
I've another question about this:
How can we apply this for Windows Server only and for Windows Server >= 2008 (2008, 2008R2, 2012....)?
We have to make a loop in which you filter, I suppose. ^_^
I don't know how to do. Can you help me? Please
Thank you! 😃
You could use the -match operator, and check if the Guest OS Fullname contains 2008, 2012 or 2016.
Something like this
Get-VM | where{$_.Guest.OSFullName -match "2008|2012|2016"} |
Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great! I try it.
Thanks for your help.
Have a good day
Hi LucD,
What do you think about this 2 scripts? What is the best?
Get-VM | Where-Object{
$_.Guest.OSFullName -match "2008|2012|2016"
} | ForEach-Object{
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
Get-View -ViewType VirtualMachine | %{$_.ReconfigVM($vmConfigSpec)}
}
Or
Get-VM | Where-Object{
$_.Guest.OSFullName -match "2008|2012|2016"
} | ForEach-Object{
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
(Get-View $_.ID).ReconfigVM($vmConfigSpec)
}
If there is errors, tell me! haha
I prefer to ask you before execute one of the two script. I'm new in scripting. :smileyblush:
Thank you for your help. :smileygrin:
The first one is wrong, it will do a reconfig for all VMs each time it loops through the outer ForEach loop. Probably not what you want.
On the 2nd one you can save a Get-View by using the ExtensionData property.
And by only constructing the some $vmConfigSpec object once, outside the loop
Like this
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
Get-VM | Where-Object{$_.Guest.OSFullName -match "2008|2012|2016"} | ForEach-Object{
$_.ExtensionData.ReconfigVM($vmConfigSpec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It work fine!
Thanks a lot Luc!
I would like to enable the option in specific vm rather than all VMS could you please help me for this.
Just i save the vm name in text file and execute the script, then option will enable in those VMS which are in text file.
Just we save the VMS name in text file or notepad then option will enable in those specific VMS which are in text file or notepad.
I don't want to enable it all the VMS please help me for this sir...
I have same doubt aflam is saying..
Please send the script and help us.
Just save the VMS name in text or notepad in certain path and execute the script then VMware tool upgrade option will enable those VMS which are saved in text or notepad file.
Please help ...
You would only need to change the last couple of lines into something like this
Get-VM -Name (Get-Content vmnames.txt) | %{
$_.Extensiondata.ReconfigVM($vmConfigSpec)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
My last reply uses a .txt file to select the VMs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference