mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-07-08 16:36:50 +02:00
27 lines
538 B
PowerShell
Executable File
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
|
|
}
|