26
Apr 13

Disable Time Synchronization on All Virtual Machines

The scenario that started my day: One of my programmers complains of time-drift on his workstation. His machine has synced to a VM domain controller, which is odd, since it’s not the PDC, doesn’t hold any FSMO roles…I’ll figure that out later.

I recall reading about the time synchronization integration feature that Hyper-V has, and the problems it can cause with VM time settings. I want to query my Hyper-V server and see if the feature is enabled for any of the VMs.

Normally I’d pull up the Hyper-V Manager GUI, right click the VM, go to integration services, blahblahblah…

BUT

Lately I’ve been looking into more and more automation – the sentiment of “Work smarter, not harder” comes to mind. If you’re a Windows admin, this means your gonna have to crack your knuckles and launch into Powershell.

For some time I’ve dreamed of being a Powershell guru – I’ve always been jealous of the guys who bang out amazing one-liners in bash, creating miracles in strings.

Sure, I’ve “scripted” a bit. I know many can relate to this: putting scripts together can be a collage-type experience; that is, Googling each piece and pulling snippets from the various resources, a little regex from StackOverflow, some modification followed by trial and error from a Technet thread, a random tool pulled from some guy’s blog.

But more and more I want to learn the tools and syntax so I can do things my way first and only ask for help later.

I’ll assume:

  • You already have RSAT tools installed/enabled on whatever machine you’re connecting from
  • You understand the terrible oversight of Microsoft to only allow 2012 management tools to be installed on Windows 8.
  • Additionally, these tools don’t allow backwards compatibility, so if you’re still using a 2008/2008 R2 HV server, you’ll need Win 7 or Server 2008 to connect via a GUI or cmdlet.

My goals:

  • Find all servers which have time sync enabled as a Hyper-V integration feature.
  • Disable feature on all servers

Note:  I’ve only tested this from my Windows 8 machine connecting to my 2012 Hyper-V server.

Open up Powershell and run:

Import-Module Hyper-V

Next, run:

1
Get-VMIntegrationservice -Name 'Time Synchronization' -ComputerName HYPERVHOST -vmname *

This cmdlet queries your HV host for the Time Synchronization feature and accepts the * wildcard for VMname, listing the features status on all VMs.

Ready to turn the feature off?

1
Disable-VMIntegrationService -name 'Time Synchronization' -Computername HYPERVHOST -Vmname *

Same idea, but instead of a query, this cmdlet disables the feature. You can run the previous command to confirm it’s now disabled on all machines.

That’s it?  Yup.  Quick and easy.