Created
May 22, 2017 14:51
-
-
Save bohack/08c9d71958ad1dad1841fecec51a6ecf to your computer and use it in GitHub Desktop.
PowerCLI to Set a VM to sync time from the host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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