Update check-dns.ps1

This commit is contained in:
Markus Fleschutz 2022-05-23 12:51:58 +02:00
parent c1b4b0b981
commit bedc512f47

View File

@ -5,19 +5,18 @@
This PowerShell script checks the DNS resolution with frequently used domain names. This PowerShell script checks the DNS resolution with frequently used domain names.
.EXAMPLE .EXAMPLE
PS> ./check-dns PS> ./check-dns
DNS resolution is 11.8 domains per second 11.8 domains per second DNS resolution
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz / License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
write-progress "Reading Data/domain-names.csv..."
$PathToRepo = "$PSScriptRoot/.." write-progress "Reading Data/domain-names.csv..."
$Table = import-csv "$PathToRepo/Data/domain-names.csv" $Table = Import-CSV "$PSScriptRoot/../Data/domain-names.csv"
if ($IsLinux) { if ($IsLinux) {
foreach($Row in $Table) { foreach($Row in $Table) {
@ -27,15 +26,14 @@ try {
} else { } else {
foreach($Row in $Table) { foreach($Row in $Table) {
write-progress "Resolving $($Row.Domain)..." write-progress "Resolving $($Row.Domain)..."
$null = resolve-dnsName $Row.Domain $null = Resolve-dnsName $Row.Domain
} }
} }
$Count = $Table.Length $Count = $Table.Length
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
$Average = [math]::round($Count / $Elapsed, 1) $Average = [math]::round($Count / $Elapsed, 1)
"$Average domains per second DNS resolution"
& "$PSScriptRoot/give-reply.ps1" "$Average domains per second DNS resolution"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"