I have a powercli script that modifies vmx files, then reloads the vmx file. Is a VM poweroff and poweron still required for the new values in the vmx file to be applied to the VM?
Script:
#disable-vmtimesync.ps1
$ExtraOptions = @{
"tools.syncTime"="0";
"time.synchronize.continue"="0";
"time.synchronize.restore"="0";
"time.synchronize.resume.disk"="0";
"time.synchronize.shrink"="0";
"time.synchronize.tools.startup"="0";
}
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
# note we have to call the GetEnumerator before we can iterate through
Foreach ($Option in $ExtraOptions.GetEnumerator()) {
$OptionValue = New-Object VMware.Vim.optionvalue
$OptionValue.Key = $Option.Key
$OptionValue.Value = $Option.Value
$vmConfigSpec.extraconfig += $OptionValue
}
# Get all vm's not including templates
$VMs = Get-View -ViewType VirtualMachine -Property Name -Filter @{"Config.Template"="false"} | ? { $_.name -eq "CTX82" }
foreach($vm in $vms){
$vm.ReconfigVM_Task($vmConfigSpec)
$vm.reload()
}
BTW, it's running on a ESX 4.0 environment.
Yes, the vmx file is read at power on (not reset or reboot)
// Linjo
Then what's the $vm.reload() do?
It reloads it in vCenter, that is needed because vCenter is caching the information from the VMX:
So the $vm.reload() reloads the vmx in vcenter, but doesn't actually 're-read' it to determine or re-determine VM properties. So, I have to power off and power on the guest in order for the vmx changes to actually take effect. Correct?
Yes, the vmx file is read at power on (not reset or reboot)
// Linjo