Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bohack/08c9d71958ad1dad1841fecec51a6ecf to your computer and use it in GitHub Desktop.
Save bohack/08c9d71958ad1dad1841fecec51a6ecf to your computer and use it in GitHub Desktop.
PowerCLI to Set a VM to sync time from the host
# Bohack
# 05/22/17
# Set time sync for VM
if ($args.count -lt 1) {
write-host
write-host "SetVMTime {VM Guest Name}"
write-host
break
}
$vm = Get-VM -Name $Args[0]
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.changeVersion = $vm.ExtensionData.Config.ChangeVersion
$spec.tools = New-Object VMware.Vim.ToolsConfigInfo
$spec.tools.syncTimeWithHost = $true
$_this = Get-View -Id $vm.Id
$_this.ReconfigVM_Task($spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment