ntp powershell (semi)

The best way to check all Domain Controllers (DC’s) for time sync is

w32tm /monitor

This will show if there are any outliers.

Here is the script I use for the DC’s, it arguable that it’s best to only do this on the PDC, but I like them on all of them.

$timeRoot = “HKLM:\SYSTEM\CurrentControlSet\services\W32Time”
# 0x8 = client mode, standard poll negotiation (well-behaved for the forest root)
$ntpServer = “time.windows.com,0x8 time.nist.gov,0x8 us.pool.ntp.org,0x8”

Set-ItemProperty -Path “$timeRoot\Parameters” -Name Type -Value “NTP”
Set-ItemProperty -Path “$timeRoot\Parameters” -Name NtpServer -Value $ntpServer
Set-ItemProperty -Path “$timeRoot\Config” -Name AnnounceFlags -Value 5 # 5 = reliable time source
Set-ItemProperty -Path “$timeRoot\Config” -Name MaxPosPhaseCorrection -Value 1800
Set-ItemProperty -Path “$timeRoot\Config” -Name MaxNegPhaseCorrection -Value 1800
Set-ItemProperty -Path “$timeRoot\TimeProviders\NtpServer” -Name Enabled -Value 1
# With 0x8 you rely on Min/MaxPollInterval, not SpecialPollInterval:
Set-ItemProperty -Path “$timeRoot\TimeProviders\NtpClient” -Name MinPollInterval -Value 6

# 2^6 = 64s
Set-ItemProperty -Path “$timeRoot\TimeProviders\NtpClient” -Name MaxPollInterval -Value 10

# 2^10 = 1024s

w32tm /config /reliable:yes /update
Restart-Service w32time
w32tm /resync /rediscover

wait a bit, and then see if you’re walking back to the ntp time!!

w32tm /stripchart /computer: time.nist.gov /samples:999 /dataonly

Leave a Reply

Your email address will not be published. Required fields are marked *