How to set your Windows server to sync time with NTP servers

Copy and paste the following into notepad and save it as a .bat  If your server doesn’t execute the commands in the order they are, remove the “rem ” from the timeout and increase the time if needed.

@echo off
echo Showing Current Config
W32tm /query /configuration
pause
echo Setting Time Souces
start /wait w32tm /config /syncfromflags:manual /manualpeerlist:"time-a-g.nist.gov,0x1 time-b-g.nist.gov,0x1 time-c-g.nist.gov,0x1" /reliable:yes /update
rem timeout /t 1
echo Updating w32tm
start /wait w32tm /config /update
rem timeout /t 1
start /wait w32tm /resync
echo Showing Current Config
start /wait W32tm /query /configuration
rem timeout /t 1
echo Showing Status
start /wait W32tm /query /status
pause