1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# =========================================================================================================== # # Created by: Trentent Tye # # Creation Date: Oct 15, 2013 # # File Name: Fix-Time-Sync.ps1 # # Description: This script will be used to resolve an issue with VMWare where the VMWare Tools cause a # time sync with the host. If the host has an incorrect time it will knock the time out of # sync on the guest. To resolve this issue some text entires need to be made to the VMX # fix. This is detailed here: # http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1189 # # =========================================================================================================== Add-PSSnapin VMware.VimAutomation.Core connect-viserver wsvcenter20 $ExtraOptions = @{ "tools.syncTime"="0"; "time.synchronize.continue"="0"; "time.synchronize.restore"="0"; "time.synchronize.resume.disk"="0"; "time.synchronize.shrink"="0"; "time.synchronize.tools.startup"="0"; "time.synchronize.tools.enable" = "0"; "time.synchronize.resume.host" = "0"; } # build our configspec using the hashtable from above. I prefer this # method over the use of files b/c it has one less needless dependency. $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec # note we have to call the GetEnumerator before we can iterate through Foreach ($Option in $ExtraOptions.GetEnumerator()) { $OptionValue = New-Object VMware.Vim.optionvalue $OptionValue.Key = $Option.Key $OptionValue.Value = $Option.Value $vmConfigSpec.extraconfig += $OptionValue } # Get all vm's starting with name: $VMView = Get-View -ViewType VirtualMachine -Filter @{"Name" = "WSCTX"} foreach($vm in $VMView){ $vm.ReconfigVM_Task($vmConfigSpec) } # Get all vm's starting with name: $VMView = Get-View -ViewType VirtualMachine -Filter @{"Name" = "WSAPV"} foreach($vm in $VMView){ $vm.ReconfigVM_Task($vmConfigSpec) } |