I'm trying to achieve the 3 goals: acquire/enable/disable the "synchronize at startup and resume" and "synchronize time periodically" of vmware tools time sync for virtual machines, and the primary codes i utilized are shown below:
# Get all VMs
$vms = Get-VM
$vmTimeSyncSettings = $vms | ForEach-Object {
$vm = $_
$tools = $vm.ExtensionData.Config.Tools
[PSCustomObject]@{
VMName = $vm.Name
SyncTimeAtStartupAndResume = $tools.SyncTimeWithHostAtPowerOnResume
SyncTimeWithHost = $tools.SyncTimeWithHost
}
}
# Display the settings
$vmTimeSyncSettings | Format-Table -AutoSize
however, there's problem obtaining the result of "synchronize at startup and resume", which the output is blank.
did i use the wrong commands to get the information of time sync setting? or maybe powercli isn't a good way to do that?