How Can We Help?

How to setup NTP Server for time synchronization using Powershell

Table of Content
setup NTP Server for time synchronization

Step 1. Login to your Windows Server

Step 2. Open Powershell as Administrator setup NTP Server for time synchronization

If the computer you want to configure is an Active Directory domain controller, the NTP server function is automatically enabled. Therefore, the following is an example of setting the NTP server function to Windows Server in a workgroup environment.

Step 3. Run the following command to check current settings

Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer"
setup NTP Server for time synchronization

Step 4. Run the following command to Enable NTP server function

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" -Name "Enabled" -Value 1
setup NTP Server for time synchronization

setup NTP Server for time synchronization

Step 5 . Change AnnounceFlags to 5

# Meaning of numbers

# 0x00 : Not a time server

# 0x01 : Always time server

# 0x02 : Automatic time server

# 0x04 : Always reliable time server

# 0x08 : Automatic reliable time server

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Config" -Name "AnnounceFlags" -Value 5
setup NTP Server for time synchronization

Step 6. Allow NTP port if Windows Firewall is running

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

Thank You!

Table of Contents