Files
PowerShell/scripts/clear-dns-cache.ps1
2025-06-23 09:58:34 +02:00

27 lines
538 B
PowerShell
Executable File

<#
.SYNOPSIS
Clears the DNS cache
.DESCRIPTION
This PowerShell script empties the DNS client cache of the local computer.
.EXAMPLE
PS> ./clear-dns-cache.ps1
✅ DNS cache cleared in 1s.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
Clear-DnsClientCache
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✅ DNS cache cleared in $($elapsed)s."
exit 0 # success
} catch {
"⚠️ Error: $($Error[0])"
exit 1
}