In this article we will discuss the main points of working with ntp through Powershell on Windows server 2012. We will do this on the domain controller. So let’s get started.

Step 1: Start and stop time service

Use this commands:

net start w32time

net stop w32time

or

stop-service w32time

start-service w32time

Step 2: Let’s specify the server with which we will synchronize time

Check if our time is synchronized with Microsoft’s public ntp server:

w32tm /stripchart /computer:time.windows.com /samples:4 /dataonly

Step 3: Choose trusted time source

Now we’ll point out that we have to synchronize with this server and say that we are a trusted time source:

w32tm /config /manualpeerlist: time.windows.com /syncfromflags:manual /reliable:yes /update

Step 4: Synchronize with several public time sources

If you need to synchronize with several public time sources, the command will look like this:

w32tm /config /manualpeerlist:“ntp1.sp.se ntp2.sp.se” /syncfromflags:MANUAL /reliable:yes /update

Step 5: Several useful commands

Useful information about time synchronization:

w32tm /query /status

Command to debug to file:

w32tm / debug / enable / file: C: \ \ / size: 10485760 / entries: 0-300

After debug let’s turn it off:

w32tm /debug /disable

Command to forcing client sync:

w32tm /resync

To reset the settings, use the command:

w32tm /unregister

Next, restore the default settings:

w32tm /register

13 Spice ups

Are steps 2 and 3 redundant or necessary repetition? Thanks in advance.

Yes, they are redundant, thanks for reporting this.
I corrected it.

Uhm, wow nice, congrats.
And where is the PS stuff?