В Windows Server 2019 и 2022 по умолчанию указан сервер времени time.windows.com. В некоторых средах он недоступен, но точное время нужно, но заменить сервер времени по умолчанию через пользовательский интерфейс затруднительно. Заменить сервер времени можно отредактировав реестр с помощью PowerShell (от имени администратора):
Проверяем текущий сервер:
w32tm /query /source
time.windows.com,0x8
Заменяем на нужный сервер времени:
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" -Name "NtpServer" -Value "pool.ntp.org,0x8"
После перезапустим службу, чтобы изменения вступили в силу и выполним синхронизацию времени:
Restart-Service w32time
w32tm /resync
Отправка команды синхронизации на локальный компьютер
Команда выполнена успешно.
Готово.
The correct date, time, and time zone are one of the first settings a Windows Server should have. In today’s article, we’ll see how we can change time, date, and time zone through the graphical environment, command line and Powershell.
Set time, date, and time zone settings from the graphical interface
The process is very simple. Right-click the time field in the lower right corner and then click the Adjust date/time option.
In the settings window, you can change the time, date, and time zones of each Windows Server. I do not think there is a need for further guidance as it is a simple process.
Alternatively, you can open the time and date settings window by clicking on the corresponding field in the Local Server section of the Server Manager.
As you will see, in this case, opens the “old” management window through which you can set the time, date and time zone.
Set time, date, and time zone settings on command prompt
By typing the following command will open the time and date setting window, even in a Server Core installation.
To display the current date and time, enter the following commands.
To set time and date, you can use the corresponding Time and Date commands at the command line.
In Windows Server 2012 have been added the Timezone Utility (tzutil) tool that allows us to display and set a time zone through the Windows command line.
First, open the command line with administrator privileges and make sure you are in the System32 folder.
To display the current Windows Server Time Zone, type the following command.
To display all available time zones, type the following command.
To change the current time zone in Windows Server, type the following command, between the doubles, enter the time zone as it appears in the list of the previous command. For example, for the Greek time zone type:
tzutil /s "GTB Standard Time"
To confirm that the time zone has changed, you can see the corresponding registry entry by using the following command from within the same command-line window.
reg query HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
[pro_ad_display_adzone id=”1683″]
Set time, date and time zone settings on Powershell
To view the current date and time, type the following command.
To set the time and date through Powershell the process is very easy. Use the following command as an example by changing the date and time values.
Set-Date -Date "06/06/2017 14:45"
Alternatively, you can simply type the Set-Date command and promptly you will be prompted to enter the server’s date and time.
To view the current time zone through Powershell, type the following command.
Before changing the time zone, you will need to know the right name. Type the following command to see all available time zones in Windows Server.
Get-TimeZone -ListAvailable
To change the time zone, use the following command along with the corresponding time zone of your server.
Set-TimeZone -Name "GTB Standard Time"
If you manage an organization’s IT infrastructure, configuring NTP is essential to ensure proper and accurate time synchronization, which enables event logging, network security, and other computer operations. In this post, we will discuss how to configure an NTP Server on a Windows Server.
Network Time Protocol (NTP) is a highly scalable internet protocol that helps determine the most accurate time information and synchronizes the time settings on a computer system.
In order to configure NTP Server on Windows Server, you can use the Windows Registry or PowerShell.
1] Configure the NTP Server using Registry Editor
First, we will see how you can configure the NTP Server with the Registry Editor. We are going to configure the Windows Registry, which is a hierarchical database used to set up your computer’s settings. To do so, you can follow the steps mentioned below.
- Take a backup of your registry.
- Then, we will enable NtpServer using the registry key and configure Win32Time’s AnnounceFlags.
- Next up, we need to restart the NTP Server.
- Finally, we will open the appropriate UDP port in Firewall.
To open the Registry Editor, we can open Run, type “regedit”, and click on Ok. Once the UAC prompts, click on Yes to continue. Now, we will take a backup of the registry that will be used if you want to revert back to the previous state in case something goes wrong. To do so, in Registry Editor, go to File > Import, go to the location where you want to store the import, and save it.
After taking the import, navigate to the following location in the Registry Editor.
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer
Look for the value called Enabled, double-click on it, and set its Value data to 1. This will enable the NTP protocol on your server.
Once done, we need to go to the following location.
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config
You need to look for AnnounceFlags, double-click on it, and set its Value data to 5.
Next, we need to restart the NTP Server, which can be done just by restarting the Time service. So, hit Win + S, search for Services, and open the utility. Now, scroll down and search for Windows Time service, right-click on it, and select Restart. Wait for the service to restart and we can move to our final step.
Finally, we are going to open the UDP Port 123 as it is used for the Network Time Protocol (NTP). To do so, you can follow the steps mentioned below.
- Open Run by Win + R, type “wf.msc”, and hit Enter to open the Windows Defender Firewall with Advanced Security utility.
- Click on Inbound Rules > New Rule.
- Select Port and click on Next.
- Next up, you need to select the UDP checkbox and in the Specific local port field, enter 123; click on Next.
- Select Allow the connection and click on Next.
- You need to select the profile where this rule is supposed to be applied; Domain, Private, or Public. Click on Next.
- Give a name of your choice along with the description and click on Next.
This will open the UDP Port 123 which will allow the NTP traffic to pass.
That’s how you can configure an NTP Server on a Windows Server.
2] Configure the NTP Server using PowerShell
The aforementioned method allows you to configure the NTP server using the GUI, but we have a CLI-based method as well. Here, we require you to open PowerShell on your machine and then run the following commands.
- In order to enable the Registry key for NTP Server, you need to run the following command.
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" -Name "Enabled" -Value 1
- Next up, we need to make AnnounceFlags value 5 by running the command mentioned below.
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Config" -Name "AnnounceFlags" -Value 5
- To restart the Time service, run – Restart-Service w32Time.
- Now, we need to configure the Firewall, for that, run the following commands.
New-NetFirewallRule ` -Name "Allow NTP" ` -DisplayName "NTP Server Port" ` -Description 'Allow NTP Server Port' ` -Profile Any ` -Direction Inbound ` -Action Allow ` -Protocol UDP ` -Program Any ` -LocalAddress Any ` -LocalPort 123
Now, you have configured an NTP Server.
Read: Change Internet Time Update interval in Windows
How to configure NTP server in Windows Server?
To configure the NTP Server in Windows Server, you must enable the related registry key. Also, you need to configure the AnnounceFlags registry value under W32Time. Once done, we need to restart the Time service and configure the UDP port to allow NTP traffic. To do all this, we recommend you follow the steps mentioned above.
Read: NTP client shows incorrect Time on Windows
How do I setup my own NTP server?
On Windows, setting up the NTP Server is actually pretty simple, all you need to do is configure the registry settings, and once that is done, you can reboot the Windows Time service and then configure the UDP port settings, as mentioned in this post above.
Also Read: Add or change Time Server in Windows.
Problem
Since Windows Server 2016 until now, with Windows Server 2022: if you want to change Time Server, you will see that the area is grayed out …
Solution
The solution is to inject the new Time server (with command line):
Open the command line (depends on the operating system used) Click Start > Windows System > Command Prompt (right click and open with More > Run as administrator).
Copy and paste this command and if necessary modify it
w32tm /config /manualpeerlist:be.pool.ntp.org /syncfromflags:manual /reliable:yes /update
In this command, we’ll change the NTP to be.pool.ntp.org
More explanation about command w32tm
https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings?tabs=config
And to change to the Brussels, Copenhagen, Madrid, Paris time zone
C:\>tzutil /s "Romance Standard Time"
More explantation about this
If you are alerted to a server that is displaying the wrong time, the following may be of use.
When you need to change NTP time source for a server, use the specific commands in this article, which refer to the following operating systems; Windows Server 2008 R2 and SBS 2011.
If you have multiple servers on a domain, please ensure you know which server has the source NTP configured, as you will need to perform the commands on that server. If you are unsure, you can issue a command that will query the time service and display some information for you.
Firstly open a command prompt as an administrator and type the following:
w32tm /query /status
Within the displayed output, the second to last item should be source and could state the following:
- Local CMOS Clock
- windows.com (typically default)
- The hostname of the source server (if more than 1 server exists on the domain)
If you wish to test a different NTP server pool you can use the following website to identify one for your location:
http://support.ntp.org/bin/view/Servers/NTPPoolServers
Once you have identified the hostname, you can issue the command below to amend the source:
Please note this must also be from an elevated command prompt
w32tm /config /manualpeerlist:chosenhostname
Please see an example below that would change the source to a UK based pool:
w32tm /config /manualpeerlist:uk.pool.ntp.org
The time service will now need to be restarted, please see the commands below:
net stop w32time
net start w32time
Once this has been done, you can run the initial query command to confirm the amended source is now in place.