mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-25 16:18:55 +01:00
27 lines
583 B
PowerShell
Executable File
27 lines
583 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
Clears the DNS cache
|
|
.DESCRIPTION
|
|
This PowerShell script clears the DNS client cache of the local computer.
|
|
.EXAMPLE
|
|
PS> ./clear-dns-cache.ps1
|
|
✅ Cleared DNS cache 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
|
|
"✅ Cleared DNS cache in $($elapsed)s."
|
|
exit 0 # success
|
|
} catch {
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|