From f41205c332a1d6edc20647a0346a0f69ca76fe45 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 8 Sep 2022 16:43:32 +0200 Subject: [PATCH] Update check-dns.ps1 --- Scripts/check-dns.ps1 | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Scripts/check-dns.ps1 b/Scripts/check-dns.ps1 index 69ca903c..147ba1ca 100755 --- a/Scripts/check-dns.ps1 +++ b/Scripts/check-dns.ps1 @@ -2,10 +2,10 @@ .SYNOPSIS Checks the DNS resolution .DESCRIPTION - This PowerShell script checks the DNS resolution with frequently used domain names. + This PowerShell script checks the DNS resolution using frequently used domain names. .EXAMPLE PS> ./check-dns - 11.8 domains per second DNS resolution + 56.7 domains per second DNS resolution .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -13,29 +13,23 @@ #> try { - $StopWatch = [system.diagnostics.stopwatch]::startNew() - - write-progress "Reading Data/domain-names.csv..." + write-progress "Reading table from Data/domain-names.csv..." $Table = Import-CSV "$PSScriptRoot/../Data/domain-names.csv" - - if ($IsLinux) { - foreach($Row in $Table) { - write-progress "Resolving $($Row.Domain)..." - $null = dig $Row.Domain +short - } - } else { - foreach($Row in $Table) { - write-progress "Resolving $($Row.Domain)..." - $null = Resolve-dnsName $Row.Domain - } - } $Count = $Table.Length + write-progress "Resolving $Count domain names..." + $StopWatch = [system.diagnostics.stopwatch]::startNew() + if ($IsLinux) { + foreach($Row in $Table) { $null = dig $Row.Domain +short } + } else { + foreach($Row in $Table) { $null = Resolve-DNSName $Row.Domain } + } [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + $Average = [math]::round($Count / $Elapsed, 1) "$Average domains per second DNS resolution" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 -} +} \ No newline at end of file