Update check-dns.ps1

This commit is contained in:
Markus Fleschutz 2022-09-08 16:43:32 +02:00
parent 09306c0156
commit f41205c332

View File

@ -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,25 +13,19 @@
#>
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