Categories
Tech

Set NTP servers for time sync in Windows with command prompt and registry

⏲ Steps to set and use an NTP server with w32tm

You probably don’t want to do this on domain joined servers unless you know why you want to.
Domain members should use DCs as time servers when possible. Consider using the ALL setting if you really want to do this.

Check this post for changing time zones.

Short Version

w32tm /config /manualpeerlist:”0.pool.ntp.org,1.pool.ntp.org”
w32tm /config /syncfromflags:manual
w32tm /config /update
See the registry section for a .reg export.

Commands

Check the existing settings with w32tm /query /source

w32tm /query /source

C:\Windows\system32>w32tm /query /source
Local CMOS Clock

Set the peer list with w32tm /config /manualpeerlist:<peers>
You need to use quotes when using multiple peers. Peers are separated by commas.
The example below uses 0.pool.ntp.org and 1.pool.ntp.org. Here’s a link for more info on using NTP servers.

w32tm /config /manualpeerlist:"0.pool.ntp.org,1.pool.ntp.org"

manualpeerlist registry path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters\NtpServer (String)

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters

Changing the peer list won’t change the syncfrom setting.
Use w32tm /config /syncfromflags:manual to change the source to the manual peer list.

w32tm /config /syncfromflags:manual

Other source options for syncfromflags
MANUAL: sync from peers in the manual peer list
DOMHIER: sync from an AD DC in the domain hierarchy – This is the default setting. The registry value for this setting is “NT5DS”.
NO: sync from none
ALL: sync from both manual and domain peers
syncfromflags registry path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters\Type (String)

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters

Update the config with w32tm /config /update

w32tm /config /update

You can force a sync with w32tm /resync

w32tm /resync

Registry

Here’s a link to a .reg file to use 0.pool.ntp.org and 1.pool.ntp.org

The raw file if you’re not into importing random .reg files from the internet.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters]
"NtpServer"="0.pool.ntp.org,1.pool.ntp.org"
"ServiceDll"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,\
  00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
  77,00,33,00,32,00,74,00,69,00,6d,00,65,00,2e,00,64,00,6c,00,6c,00,00,00
"ServiceDllUnloadOnStop"=dword:00000001
"ServiceMain"="SvchostEntry_W32Time"
"Type"="NTP"

I couldn’t work in a joke about going back in time.