Update check-dns.ps1

This commit is contained in:
Markus Fleschutz 2023-03-02 08:40:18 +01:00
parent 328decd842
commit 904ccf83b5

View File

@ -13,11 +13,10 @@
#> #>
try { try {
Write-Progress "Loading Data/popular-domains.csv..." Write-Progress "Resolving 200 popular domains..."
$Table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv" $Table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
$NumRows = $Table.Length $NumRows = $Table.Length
Write-Progress "⏳ Resolving $NumRows popular domains..."
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) { if ($IsLinux) {
foreach($Row in $Table){$nop=dig $Row.Domain +short} foreach($Row in $Table){$nop=dig $Row.Domain +short}
@ -27,12 +26,12 @@ try {
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds [float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
$Average = [math]::round($NumRows / $Elapsed, 1) $Average = [math]::round($NumRows / $Elapsed, 1)
Write-Progress -completed "."
if ($Average -gt 10.0) { if ($Average -gt 10.0) {
Write-Host "✅ DNS resolution is $Average domains per second" Write-Host "✅ DNS resolution is $Average domains per second"
} else { } else {
Write-Host "⚠️ DNS resolution is $Average domains per second only!" Write-Host "⚠️ DNS resolution is $Average domains per second only!"
} }
Write-Progress -completed " "
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"