Created
January 7, 2022 15:02
-
-
Save d4rkeagle65/4574ceb635b6478eedb9e530615001d2 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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