VMware Cloud Community
jcw999
Contributor
Contributor

Editing & Reloading VMX files: Reboot Required?

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()

}

-- Jeff VCP4
Tags (3)
0 Kudos
6 Replies
jcw999
Contributor
Contributor

BTW, it's running on a ESX 4.0 environment.

-- Jeff VCP4
0 Kudos
Linjo
Leadership
Leadership

Yes, the vmx file is read at power on (not reset or reboot)

// Linjo

Best regards, Linjo Please follow me on twitter: @viewgeek If you find this information useful, please award points for "correct" or "helpful".
0 Kudos
jcw999
Contributor
Contributor

Then what's the $vm.reload() do?

-- Jeff VCP4
0 Kudos
Linjo
Leadership
Leadership

It reloads it in vCenter, that is needed because vCenter is caching the information from the VMX:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=102604...

Best regards, Linjo Please follow me on twitter: @viewgeek If you find this information useful, please award points for "correct" or "helpful".
0 Kudos
jcw999
Contributor
Contributor

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?

-- Jeff VCP4
0 Kudos
Linjo
Leadership
Leadership

Yes, the vmx file is read at power on (not reset or reboot)

// Linjo

Best regards, Linjo Please follow me on twitter: @viewgeek If you find this information useful, please award points for "correct" or "helpful".
0 Kudos