PowerCLI

 View Only
  • 1.  Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 05:07 PM

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

    }



  • 2.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 05:16 PM

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



  • 3.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 06:00 PM

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

    // Linjo



  • 4.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 06:02 PM

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



  • 5.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 06:05 PM

    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=1026043



  • 6.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 06:33 PM

    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?



  • 7.  RE: Editing & Reloading VMX files: Reboot Required?

    Posted Feb 12, 2014 07:05 PM
    Yes, the vmx file is read at power on (not reset or reboot)

    // Linjo