Clears the local resolver cache and reports the entry count before and after, so the run history shows that something was actually flushed. The fix for a host still resolving a record you moved an hour ago, and safe to chain after any DNS change.
powershell
# Flush DNS Client Cache
# Single use case: clear the local DNS resolver cache (stale record fix)
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
$before = (Get-DnsClientCache -ErrorAction SilentlyContinue | Measure-Object).Count
Write-Log "DNS cache entries before flush: $before"
Clear-DnsClientCache -ErrorAction SilentlyContinue
$after = (Get-DnsClientCache -ErrorAction SilentlyContinue | Measure-Object).Count
Write-Log "DNS cache entries after flush: $after"
Write-Log "DNS client cache flushed."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.
More in Self-Healing & Repair
Clear the Windows Update Cache with PowerShell
2026-08-17Automate Disk Cleanup with PowerShell
2026-08-17Remove Windows Bloatware Apps with PowerShell
2026-08-17Clear a Stuck Print Queue with PowerShell
2026-08-17Delete Old Temp Files with PowerShell
2026-08-17Repair Windows System Files with DISM and SFC
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.