Script to enable update vmtool at power cycle and Manual
Using below script you can enable and disable VMtool update. You can schedule VMtool update using VUM as well.
#Script to update Vmtool on power cycle
Connect-VIServer -Server VCSA7.ads.com
$VM = Get-Content "c:\temp\VM_list.txt"
foreach ($i in $VM){
$vm = Get-VM -Name $i | % {Get-View $_.ID}
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "upgradeAtPowerCycle”
$vm.ReconfigVM($vmConfigSpec)
}
VM_List -> Put list of the VMs on which you want to update VMTool
=======================================
Script to Disable update vmtool at power cycle
#Script to change the VM update at power cycle to Manual
Connect-VIServer -Server VCSA7.ads.com
$VM = Get-Content "c:\temp\VM_list.txt"
foreach ($i in $VM){
$vm = Get-VM -Name $i | % {Get-View $_.ID}
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "Manual”
$vm.ReconfigVM($vmConfigSpec)
}
If it help you please comment.
ReplyDelete