Skip to content

Instantly share code, notes, and snippets.

@SunsetMkt
Forked from d4rkeagle65/Configure-NTPServer.ps1
Created April 16, 2026 16:36
Show Gist options
  • Select an option

  • Save SunsetMkt/72b95a6ca487ef584e7172a118301644 to your computer and use it in GitHub Desktop.

Select an option

Save SunsetMkt/72b95a6ca487ef584e7172a118301644 to your computer and use it in GitHub Desktop.
Enables Windows Server to server NTP to clients on a network and configures the upstream time server to time.windows.com. Also creates a firewall rule to allows incoming connections to UDP port 123 for NTP clients.
Set-TimeZone -Name 'Eastern Standard Time'
Set-Service -Name W32Time -StartupType Automatic
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer' -Name 'Enabled' -Value 1 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config' -Name 'AnnounceFlags' -Value 0xA -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient' -Name 'Enabled' -Value 1 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient' -Name 'SpecialPollInterval' -Value 300 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name 'Type' -Value 'NTP' -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters' -Name 'NtpServer' -Value 'time.windows.com,0x8' -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config' -Name 'MaxPosPhaseCorrection' -Value 1800 -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Config' -Name 'MaxNegPhaseCorrection' -Value 1800 -Force
New-NetFirewallRule `
-Name "NTP Server Port" `
-DisplayName "NTP Server Port" `
-Description 'Allow NTP Server Port' `
-Profile Any `
-Direction Inbound `
-Action Allow `
-Protocol UDP `
-Program Any `
-LocalAddress Any `
-LocalPort 123
Restart-Service -Name W32Time -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment