Script: Totally disable VM timesync towards the host


PowerCLI_Icon_48x48Production systems should at all times have correct time, but sometimes time drifts, or your NTP services stops or of some reason don’t works as intended.  VMware tools have a feature you can synchronize time from the virtual machine against the host it’s running on, which you can enable or disable.
I would recommend that all virtual and physical machines should be pointed to a NTP service, eighter within your environment, or to an external NTP service and not synchronize to the local ESXi host!
And heres why
Every time a snapshot is taken, the virtual machine is suspended or resumed or if it’s vmotioned to another host, time will synchronize towards the host – EVEN if the «Time Synchronization with host» is disabled (see my other post to determine if this is enabled or disabled for your virtual machines).  If time and date are incorrect on he host, the virtual machine will get this same incorrect values!

How to avoid thisEdit_VM_Settings_01
You can add some values to the «Advanced Edit_VM_Settings_02Settings» to your virtual machines to completely avoid this issue, like the pictures at the right shows.  But, these settings are only available while the virtual machine is powered off.  Editing the .vmx file directly on a host will not be possible eighter, because it’s locked.
So, how can we do this without powering off the virtual machines, on one or all virtual machines at once ?  Yes – with a PowerCLI script as posted below.

 

Please note that when the script add these settings, the settings will not be effected until the next reboot of the virtual machine because it have to load the new settings.  But, you can now prepare everything in advance of a service windows!

[snippet id=»35″]

Dette innlegget ble publisert i Generell, PowerCLI, VMware. Bokmerk permalenken.