Windows PowerShell:- Changing time on a Server
Checking and changing the source time server on a VM or host has never been easier than running a simple command to change it.
Many times, VM’s and hosts lose time and you end up with Services like Exchange or domain controllers out of sync and then stuff stops working.
To firstly check where your VM or host is getting its time from is by querying the status of w32tm by running this command:
- w32tm /query /status
As you can see above, this server I am working on is getting its time from “time.windows.com”
Now to change the time, you can run the following command:
- w32tm /config /syncfromflags:manual /manualpeerlist:”NTP Server” /reliable:yes /update
As shown above, the command ran successfully, change the name NTP Server to the peer you want to use.
Now if you run the first command again, you will see the change. I normally restart the time service once done.
Hope it helps.