Skip to content

Instantly share code, notes, and snippets.

@Archmonger
Last active January 11, 2026 09:44
Show Gist options
  • Select an option

  • Save Archmonger/a19098e1cb92c027d91c32bf3e36cfb9 to your computer and use it in GitHub Desktop.

Select an option

Save Archmonger/a19098e1cb92c027d91c32bf3e36cfb9 to your computer and use it in GitHub Desktop.
In theory, this script performs everything possible to fix Windows time synchronization errors. Make sure to run this script as administrator.
Write-Host "--- DIAGNOSTICS START ---"
Write-Host "Checking Group Policy Overrides..."
if (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\W32Time") {
Write-Host "WARNING: Group Policy for Time Service detected!"
Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\W32Time\*" | Select-Object *
} else {
Write-Host "No Group Policy found."
}
Write-Host "Checking Current Registry Parameters..."
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" | Select-Object NtpServer, Type
Write-Host "Checking Recent Event Logs..."
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-Time-Service'} -MaxEvents 5 -ErrorAction SilentlyContinue | Format-Table TimeCreated, Id, Message -Wrap
Write-Host "--- ATTEMPTING FIX ---"
Write-Host "Stopping Service..."
Stop-Service W32Time
Write-Host "Removing Group Policy (if exists)..."
if (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\W32Time") {
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\W32Time" -Recurse -Force
Write-Host "Group Policy removed."
}
Write-Host "Unregistering..."
w32tm /unregister
Start-Sleep -Seconds 3
Write-Host "Registering..."
w32tm /register
Start-Sleep -Seconds 3
Write-Host "Starting Service..."
Start-Service W32Time
Start-Sleep -Seconds 3
Write-Host "Configuring 'time.windows.com'..."
w32tm /config /manualpeerlist:"time.windows.com,0x9" /syncfromflags:manual /reliable:YES /update
Write-Host "Waiting 5 seconds..."
Start-Sleep -Seconds 5
Write-Host "Triggering Resync..."
w32tm /resync
Start-Sleep -Seconds 2
Write-Host "--- FINAL STATUS ---"
w32tm /query /peers
w32tm /query /status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment