diff --git a/Scripts/check-dns.ps1 b/Scripts/check-dns.ps1 index ca2b05cb..086a553c 100755 --- a/Scripts/check-dns.ps1 +++ b/Scripts/check-dns.ps1 @@ -1,11 +1,11 @@ <# .SYNOPSIS - Checks the DNS resolution + Check DNS resolution .DESCRIPTION - This PowerShell script measures the DNS resolution speed by using 200 popular domains. + This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains. .EXAMPLE PS> ./check-dns - ✅ DNS resolution is 440.5 domains per second + ✅ DNS resolves 156.5 domains per second .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -14,24 +14,24 @@ try { Write-Progress "⏳ Resolving 200 popular domains..." - $Table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv" - $NumRows = $Table.Length + $table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv" + $numRows = $table.Length - $StopWatch = [system.diagnostics.stopwatch]::startNew() + $stopWatch = [system.diagnostics.stopwatch]::startNew() if ($IsLinux) { - foreach($Row in $Table){$nop=dig $Row.Domain +short} + foreach($row in $table){$nop=dig $row.Domain +short} } else { - foreach($Row in $Table){$nop=Resolve-DNSName $Row.Domain} + foreach($row in $table){$nop=Resolve-DNSName $row.Domain} } - [float]$Elapsed = $StopWatch.Elapsed.TotalSeconds + [float]$elapsed = $stopWatch.Elapsed.TotalSeconds - $Average = [math]::round($NumRows / $Elapsed, 1) - if ($Average -gt 10.0) { - "✅ DNS resolution is $Average domains per second" + Write-Progress -completed "." + $average = [math]::round($numRows / $elapsed, 1) + if ($average -gt 10.0) { + "✅ DNS resolves $average domains per second" } else { - "⚠️ DNS resolution is $Average domains per second only!" + "⚠️ DNS resolves $average domains per second only!" } - Write-Progress -completed "Done." exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"