Skip to content

Geekphreek

Geeks, not nerds

Domain Time Fix when VM/Hyper-V hosted DCs are involved

Posted on September 17, 2013April 14, 2015 By Geekphreek 2 Comments on Domain Time Fix when VM/Hyper-V hosted DCs are involved

So I’m part the way through sorting out my new spanky AD on Windows 2012 using Hyper-V and I start to notice time drift.  Not just a little either, we’re slipping minutes a day.

Now usually this would be simple, we just tell the time server master a la PDC emulator to go out the interwebz and grab the time.  Uh Uh Uh, you’re running your PDC emulator on a VM baby and it’s definitely grabbing it’s time from the VM Node.  Okay, we’ll just update the VM Node time via the interwebz then…. Uh Uh Uh, it’s a member of your domain so it’s getting the time from the PDC emulator.

Yup, and so begins the circle of death by W32tm.  Luckily, you can break out the cycle.  Per DC and including the VM Nodes, run this bad boy:

@echo off

cls
echo TIME SOURCE SET
echo ===============
echo.
echo Finding PDC…
:: Retrieve PDC name; delims is a dot, followed by a space and a tab
for /f “tokens=2 delims=. ” %%A IN (‘netdom query /domain:%USERDOMAIN% fsmo 2^>NUL ^| find.exe “PDC”‘) DO SET PDC=%%A
IF NOT DEFINED PDC GOTO NoPdcFound

echo Turning off VM Sync
:: Turn off VM Time
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider /v Enabled /t reg_dword /d 0

:: Check if this machine is a PDC
if NOT %COMPUTERNAME%==%%A goto DCTIME
:: PDC Stuff

:: Get time from Internet
echo Setting time server
w32tm /config /manualpeerlist:“0.pool.ntp.org,0x1” /syncfromflags:MANUAL /reliable:yes

:: Set the time
echo Setting the system time
w32tm /config /update w32tm /resync w32tm /resync /rediscover
goto end

:DCTIME
:: Set the time
w32tm /config /update w32tm /resync w32tm /resync /rediscover

:: Check the system
w32tm /query /status
w32tm /query /source

w32tm /config /syncfromflags:DOMHIER /update
net stop w32time
net start w32time
w32tm /resync /force

goto end

:NoPdcFound
echo Cannot find your PDC. Quitting
pause
exit
:end
echo Time services set
pause

From the top, it disables getting time from the VM Node/Host/Hardware.  It finds the PDC and if it is running on it then sets the time source to the internet time keepers.  If not, it sets the time to come from the domain PDC which in turn is getting it’s time from the web time watchers.

Issue cured.

Post navigation

Previous Post: Hyper-V High Availability with NO Hardware NAS
Next Post: AD Powershell commands on a Windows 2003 domain

Comments (2) on “Domain Time Fix when VM/Hyper-V hosted DCs are involved”

  1. Jesse Balingit says:
    July 3, 2014 at 8:27 pm

    this script fails…

    TIME SOURCE SET
    ===============

    Finding PDCà
    2 was unexpected at this time.
    C:\Users\Administrator>

    Log in to Reply
  2. worldofmercenaries.pl says:
    August 2, 2014 at 9:59 pm

    Your website must give you a clear message using a goal-oriented direction, setting you apart from your
    competition. The truth is, people join MLM opportunities because of who introduced them.
    ” Employees at Nike are encouraged to get curious and offered to new ideas, whatever their source.

    Look at my homepage … business – worldofmercenaries.pl –

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • Monterey and VirtualBox
  • Auto-encode library with FFmpeg
  • Exchange Upgrade CU23 Fail with Cert Error
  • Changing image sizes in place in bulk
  • Download Wistia Embedded Video

Recent Comments

  • sha0z13 on EditShare Project Backup automation
  • Ilek82 on EditShare Project Backup automation
  • celewin on EditShare Project Backup automation
  • Geekphreek on EditShare Project Backup automation
  • LeoLick on EditShare Project Backup automation

Archives

Copyright © 2025 Geekphreek.

Powered by PressBook Grid Dark theme