Updated check-dns.ps1

This commit is contained in:
Markus Fleschutz 2024-12-27 09:21:09 +01:00
parent 587732eb3f
commit 64bcdee5e8

View File

@ -5,7 +5,7 @@
This PowerShell script measures the DNS resolution speed using 100 internet domains and prints it. This PowerShell script measures the DNS resolution speed using 100 internet domains and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-dns.ps1 PS> ./check-dns.ps1
Internet DNS lookups in 33.6ms Internet DNS: 33.6ms lookup time
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -24,10 +24,12 @@ try {
} }
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds * 1000.0 [float]$elapsed = $stopWatch.Elapsed.TotalSeconds * 1000.0
$speed = [math]::round($elapsed / $table.Length, 1) $speed = [math]::round($elapsed / $table.Length, 1)
if ($speed -gt 100.0) { if ($speed -lt 10.0) {
Write-Host "⚠️ Internet DNS lookups take $($speed)ms!" Write-Output "✅ Internet DNS: $($speed)ms excellent lookup time"
} elseif ($speed -lt 100.0) {
Write-Output "✅ Internet DNS: $($speed)ms lookup time"
} else { } else {
Write-Host "✅ Internet DNS lookups in $($speed)ms" Write-Output "⚠️ Internet DNS: $($speed)ms slow lookup time"
} }
exit 0 # success exit 0 # success
} catch { } catch {