Wednesday, August 27, 2014

Active Directory clients and server not synchronizing time (In a Hyper-V environment)

I had a problem with the Active Directory servers and clients I was setting up from scratch. They would not keep time and were constantly 5-6 minutes slow. I would reset the Primary Domain Controller clock (PDC) to correct time, then wait for the time to sync down to clients but it would fall back to being slow again. I was doing a lot of troubleshooting with w32tm but really getting nowhere - until I found this post and realized the problem was due to virtual machines losing time.

All clients were synching to the PDC, but the PDC was synching to the Hyper-V host, which had inaccurate time. Even when I manually changed the time source on our PDC using the command below, it did not work because the PDC quickly reverted to synching to the Hyper-V host machine.

PS C:\Users\Administrator> w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org"

A few moments later

PS C:\Users\Administrator> w32tm /query /source VM IC Time Synchronization Provider

The solution was to manually change the time source on the Hyper-V host

PS C:\Users\Administrator> w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org"
PS C:\Users\administrator.TDG> net stop w32time
The Windows Time service is stopping.
The Windows Time service was stopped successfully.

PS C:\Users\administrator.TDG> net start w32time
The Windows Time service is starting.
The Windows Time service was started successfully.

PS C:\Users\administrator.TDG> w32tm /resync
Sending resync command to local computer
The command completed successfully.
PS C:\Users\administrator.TDG> w32tm /query /source
0.pool.ntp.org

Once this is done, go back to the guest PDC and run a resync

PS C:\Users\Administrator> w32tm /resync
Sending resync command to local computer
The command completed successfully.
PS C:\Users\Administrator> w32tm /query /source
VM IC Time Synchronization Provider

Without prompting a manual resync, the corrected time may be delayed in propagating across your domain.