PowerShell/Scripts/clear-dns-cache.ps1

26 lines
551 B
PowerShell
Raw Normal View History

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
PS> ./clear-dns-cache
.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
"✔️ cleared DNS cache in $Elapsed ms."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}