Reputation: 1646
Every time I add a computer to my network I run a script to set everything up as needed. One of the actions I need to perform is making the new computer's clock synchronize with a certain computer on the network (i.e. ip x.x.x.x).
I know I could make it sync once using:
NET TIME \\x.x.x.x /SET /Y
But I want the computers to stay synced with x.x.x.x (as would happen with an internet server if I manually chose "synchronize with an internet time server" in "internet time settings").
Is there a Powershell command that will change Windows' settings so it will keep sync with x.x.x.x? (I know I can write a script to run the above command e.g. every day and make it run on startup on each of the machines on the network, but I prefer adding a line (or a couple) to the script I run once when setting up a new machine)
Thank you!
Upvotes: 2
Views: 3303
Reputation: 13452
You can configure the Windows time service (w32time
) with the w32tm
tool to sync from another machine (via NTP) in PowerShell like this:
Start-Process w32tm -ArgumentList "/config /update /manualpeerlist:x.x.x.x /syncfromflags:MANUAL"
Where:
x.x.x.x
is your IP address/config
to configure w32time
service/update
to apply the new config immediately/manualpeerlist:
to define the source where to sync from/syncfromflags:MANUAL
to make sure that no other sources than the manually defined peer list are usedUpvotes: 3