2022-05-09 16:18:05 +02:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Clears the DNS cache
|
|
|
|
|
.DESCRIPTION
|
2022-05-09 16:20:18 +02:00
|
|
|
|
This PowerShell script clears the DNS client cache of the local computer.
|
2022-05-09 16:18:05 +02:00
|
|
|
|
.EXAMPLE
|
2023-08-06 21:35:36 +02:00
|
|
|
|
PS> ./clear-dns-cache.ps1
|
|
|
|
|
✔️ cleared DNS cache in 0 ms
|
2022-05-09 16:18:05 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
|
|
2022-05-09 16:20:18 +02:00
|
|
|
|
Clear-DnsClientCache
|
2022-05-09 16:18:05 +02:00
|
|
|
|
|
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
2023-08-06 21:35:36 +02:00
|
|
|
|
"✔️ cleared DNS cache in $Elapsed sec"
|
2022-05-09 16:18:05 +02:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|