← script library

Force a Windows Time Sync with PowerShell

Self-Healing & RepairAugust 17, 2026

Starts W32Time if it is not running, forces a resync, and logs the clock and the active time source before and after. The remediation half of the time sync check, and the fix for the Kerberos failures that clock skew produces on a domain member.

powershell
# Resync System Time
# Single use case: force an NTP resync (fix Kerberos/clock-skew issues)
#-----------------------------------------------------------------

function Write-Log {
    param($Message)
    Write-Host "<WRITE-LOG = `"*$Message*`">"
}

$svc = Get-Service -Name W32Time -ErrorAction SilentlyContinue
if ($null -eq $svc) { Write-Log "W32Time service not found!"; return }

if ($svc.Status -ne "Running") {
    Write-Log "W32Time is $($svc.Status) - starting..."
    Start-Service -Name W32Time -ErrorAction SilentlyContinue
    Start-Sleep 2
}

Write-Log "Time before resync: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"

$out = w32tm /resync /force 2>&1 | Out-String
if ($out -match "completed successfully") {
    Write-Log "Time resync completed successfully."
} else {
    Write-Log "Resync result: $($out.Trim())"
    Write-Log "If this failed, check the NTP source with 01-CHECK-TimeSync.ps1."
}

$source = (w32tm /query /source 2>&1 | Out-String).Trim()
Write-Log "Current time source: $source"
Write-Log "Time after resync: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.