Randomly selects a public NTP server and synchronizes Windows Time Service (w32time).
-
Randomly selects one of the following public NTP servers:
time.stdtime.gov.tw(Taiwan National Standard Time)time.google.comtime.cloudflare.com
-
Starts the Windows Time service if necessary.
-
Updates the configured NTP server.
-
Forces an immediate time synchronization.
-
Displays the current synchronization status.
Measuring the "fastest" NTP server sounds nice in theory, but many public NTP servers either:
- Block ICMP (ping)
- Ignore custom UDP NTP probes
- Behave differently depending on network conditions
In practice, randomly selecting from several reliable public servers provides a simple and dependable solution without adding unnecessary complexity.
- Windows 10 / Windows 11
- PowerShell 5.1 or PowerShell 7
- Administrator privileges
Run the script as Administrator:
.\RandomNtpAndSync.ps1Or configure it to run automatically using Windows Task Scheduler.
Recommended settings:
- Trigger: At startup or At logon
- Run with highest privileges
flowchart LR
Start --> Random
Random -->|Taiwan| TW[time.stdtime.gov.tw]
Random -->|Google| GO[time.google.com]
Random -->|Cloudflare| CF[time.cloudflare.com]
TW --> Sync
GO --> Sync
CF --> Sync
Sync --> Finish
Selected NTP: time.cloudflare.com
The command completed successfully.
Sending resync command to local computer...
The command completed successfully.
Source: time.cloudflare.com,0x8
Last Successful Sync Time: 2026-06-25 20:38:42
MIT License