Skip to content

Commit f41205c

Browse files
author
Markus Fleschutz
committed
Update check-dns.ps1
1 parent 09306c0 commit f41205c

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

Scripts/check-dns.ps1

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,34 @@
22
.SYNOPSIS
33
Checks the DNS resolution
44
.DESCRIPTION
5-
This PowerShell script checks the DNS resolution with frequently used domain names.
5+
This PowerShell script checks the DNS resolution using frequently used domain names.
66
.EXAMPLE
77
PS> ./check-dns
8-
11.8 domains per second DNS resolution
8+
56.7 domains per second DNS resolution
99
.LINK
1010
https://github.com/fleschutz/PowerShell
1111
.NOTES
1212
Author: Markus Fleschutz | License: CC0
1313
#>
1414

1515
try {
16-
$StopWatch = [system.diagnostics.stopwatch]::startNew()
17-
18-
write-progress "Reading Data/domain-names.csv..."
16+
write-progress "Reading table from Data/domain-names.csv..."
1917
$Table = Import-CSV "$PSScriptRoot/../Data/domain-names.csv"
18+
$Count = $Table.Length
2019

20+
write-progress "Resolving $Count domain names..."
21+
$StopWatch = [system.diagnostics.stopwatch]::startNew()
2122
if ($IsLinux) {
22-
foreach($Row in $Table) {
23-
write-progress "Resolving $($Row.Domain)..."
24-
$null = dig $Row.Domain +short
25-
}
23+
foreach($Row in $Table) { $null = dig $Row.Domain +short }
2624
} else {
27-
foreach($Row in $Table) {
28-
write-progress "Resolving $($Row.Domain)..."
29-
$null = Resolve-dnsName $Row.Domain
30-
}
25+
foreach($Row in $Table) { $null = Resolve-DNSName $Row.Domain }
3126
}
32-
$Count = $Table.Length
33-
3427
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
28+
3529
$Average = [math]::round($Count / $Elapsed, 1)
3630
"$Average domains per second DNS resolution"
3731
exit 0 # success
3832
} catch {
3933
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
4034
exit 1
41-
}
35+
}

0 commit comments

Comments
 (0)