I had a question this morning about setting tools to synchronize time with the host, and I wanted to share the results. Thanks to LucD for the outline.
Get-VM | % { Get-View $_.ID} | ` % { $spec = new-object VMware.Vim.VirtualMachineConfigSpec $spec.tools = New-Object VMware.Vim.ToolsConfigInfo $spec.tools.syncTimeWithHost = $true Get-View($_.ReconfigVM_Task($spec)) }
This question might be a little bit off topic but it refers to the same problem of setting time sync in a bunch of Windows guests.
Is there also the possibility to deactivate the Time Service in Windows guests using Power Shell? KB article http://kb.vmware.com/kb/1318 stats that this should be done when configuring the VMware Tools for being responsible for time sync.
I haven't tried it but how about:
Stop-Service w32time
Set-Service w32time -StartupType Disabled
Andrew
Hi Andy,
thanks for the suggestion after a little playing around I found a way to do this remotely:
to start: (Get-WmiObject -computer <put-computername-here> Win32_Service -Filter "Name='w32Time'").StartService()
to stop: (Get-WmiObject -computer <put-computername-here> Win32_Service -Filter "Name='w32Time'").StopService()
for status query: Get-WmiObject -computer <put-computername-here> Win32_Service -Filter "Name='w32Time'"
Regards,
daniel
Is it possible to query for time sync in VI SDK 2.0.1?
We are just running VC 2.0.2
The SDK API Reference seems to state that it is only available as from SDK 2.5.
See ToolsConfigInfo
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there any pre-requisites to using this? I have powershell and the vm pack installed ... I however get failures about $host.SetShouldExit
Not sure if I need to set something before hand?
Thanks
Matt
Shouldn't be any prerequisites. I don't understand your error, could you post the error message?
Hi,
I managed to get it sorted over the weekend - so all is well. I actually used your script and formatted it like another post which was setting the tools upgrade flag. If it useful I can post this as well?
Thanks
Hi all,
I wanted to run an audit of the syncTimeWithHost property (rather than just set it across all VMs). However, whenever I look at my VMs, this property is always null, e.g.
$vm = Get-VM -name server
$view = get-view $vm.ID
$config = $view.config
$tools = $config.tools
$tools
ToolsVersion : 55869
AfterPowerOn : True
AfterResume : True
BeforeGuestStandby : True
BeforeGuestShutdown : True
BeforeGuestReboot : False
ToolsUpgradePolicy :
PendingCustomization :
SyncTimeWithHost :
DynamicType :
DynamicProperty :
Why is the SyncTimeWithHost property always null (even though it is set as true withint the VMTools gui on the guest)?
Any ideas? Many thanks.