By default, your Windows 11 system syncs its clock with Microsoft’s time server, typically time.windows.com. However, there are occasions when you might need to use a different NTP (Network Time Protocol) server. This could be due to the default server being unreachable or a preference for a local time server in your region. Here’s are two ways to accomplish this: manually using PowerShell Prompt and automatically using a PowerShell script.

Method 1: Manually Change the NTP Time Server Using Command Prompt

  1. Open Command Prompt as Administrator:
    • Press Win + X and select “Windows Terminal (Admin)” or search for “cmd” in the Start menu, right-click, and choose “Run as administrator.”
  2. Enter the Command to Change the NTP Server:
    • In the Command Prompt window, type the following command to set your desired NTP server. If you prefer a server in India, you can use 0.in.pool.ntp.org:
w32tm /config /syncfromflags:manual /manualpeerlist:0.in.pool.ntp.org
  1. Apply the Changes:
    • Press Enter after typing the command. This will configure your system to use the new NTP server.
  2. Update the Configuration:
    • To ensure the changes take effect, type the following command and press Enter:
w32tm /config /update
  1. Resync Your System Clock:
    • Finally, synchronize your system clock with the new NTP server by entering this command:
w32tm /resync

This will update your system clock to match the specified NTP server.

Troubleshooting Time Sync Issues

If you encounter issues during the time sync process, such as errors while running the w32tm /resync command, follow these troubleshooting steps:

  1. Restart the Windows Time Service:
    • Execute the following commands to stop and restart the time service:
net stop w32time
net start w32time
  1. Resync the Clock Again:
    • After restarting the service, try syncing the clock again using:w32tm /resync
  2. Re-register the Windows Time Service:
    • If restarting the service doesn’t resolve the issue, unregister and re-register the time service:
w32tm /unregister
net stop w32time
w32tm /register
net start w32time

By following these steps, you can effectively manage and troubleshoot the time synchronization settings on your Windows 11 system. Using a local NTP server like 0.in.pool.ntp.org can ensure more accurate and reliable timekeeping for users in India.

Method 2: Automate the Process with a PowerShell Script

In response to a request by a respected reader, the process has been automated and enhanced with a PowerShell script to provide detailed feedback on each step and to help users troubleshoot any issues encountered during execution. Additionally, I’ve included my branding, and if you find this script helpful, I invite you to consider a small donation via PayPal.

Watch the Quick Demo Video Below!
For a visual walkthrough, check out the 55-second video below. It shows the process step-by-step, and the script for PowerShell method is available right below the video.

# Automated Script to Change NTP Time Server and Synchronize Time with Detailed Explanations
# Created by Jaspreet Singh
# If you find this script useful, consider donating via PayPal. Donation details are available on my blog at https://www.jaspreet.net.

# Prompt the user to enter the desired NTP server
$ntpServer = Read-Host -Prompt "Please enter your desired NTP server (e.g., 0.in.pool.ntp.org)"

# Function to log and display messages to the user
function LogMessage {
    param (
        [string]$message,
        [string]$status = "INFO"
    )
    $color = if ($status -eq "ERROR") { "DarkYellow" } else { "Green" }
    Write-Host "${status}: ${message}" -ForegroundColor $color
}

LogMessage "Starting NTP Time Server configuration process ..."

# Function to run a command and check for errors
function RunCommand {
    param (
        [string]$command,
        [string]$successMessage,
        [string]$errorMessage
    )
    $result = Start-Process cmd.exe -ArgumentList "/c $command" -NoNewWindow -Wait -PassThru
    if ($result.ExitCode -eq 0) {
        LogMessage $successMessage
    } else {
        LogMessage $errorMessage "ERROR"
        throw $errorMessage
    }
}

# Step 1: Configure the NTP Server
try {
    LogMessage "Configuring NTP server to use $ntpServer ..."
    RunCommand "w32tm /config /syncfromflags:manual /manualpeerlist:$ntpServer" "Success! NTP server is now set to $ntpServer." "Failed to configure the NTP server. Please verify the server address or check permissions."
} catch {
    exit
}

# Step 2: Apply the Configuration
try {
    LogMessage "Applying the new NTP server configuration ..."
    RunCommand "w32tm /config /update" "Configuration update applied successfully." "Failed to apply the NTP configuration. The Windows Time service may not be running."
} catch {
    LogMessage "Attempting to start the Windows Time service ..."
    RunCommand "net start w32time" "Windows Time service started successfully." "Failed to start the Windows Time service."
    RunCommand "w32tm /config /update" "Configuration update applied successfully after starting Windows Time service." "Failed to apply the NTP configuration after starting the service."
}

# Step 3: Resync the System Clock
try {
    LogMessage "Synchronizing system clock with the NTP server ..."
    RunCommand "w32tm /resync" "The system clock is now synchronized with $ntpServer." "Failed to synchronize the system clock. The Windows Time service may not be running."
} catch {
    LogMessage "Attempting to restart the Windows Time Service to resolve the synchronization issue ..." "WARNING"
    
    # Step 4: Restart Windows Time Service
    try {
        RunCommand "net stop w32time" "Windows Time service stopped successfully." "Unable to stop the Windows Time service."
        RunCommand "net start w32time" "Windows Time service started successfully." "Unable to start the Windows Time service."
        RunCommand "w32tm /resync" "The system clock has now been synchronized after restarting the Windows Time service." "Failed to synchronize the system clock after restarting the service."
    } catch {
        LogMessage "Error: All synchronization attempts failed. Please verify the NTP server and network connection." "ERROR"
        exit
    }
}

LogMessage "NTP Time Server configuration and synchronization process complete."
LogMessage "Script created by Jaspreet Singh. If you found this script useful, consider donating via PayPal. Details are available at https://www.jaspreet.net." "INFO"