2
2
. SYNOPSIS
3
3
Checks the DNS resolution
4
4
. 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.
6
6
. EXAMPLE
7
7
PS> ./check-dns
8
- 11.8 domains per second DNS resolution
8
+ 56.7 domains per second DNS resolution
9
9
. LINK
10
10
https://github.com/fleschutz/PowerShell
11
11
. NOTES
12
12
Author: Markus Fleschutz | License: CC0
13
13
#>
14
14
15
15
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..."
19
17
$Table = Import-CSV " $PSScriptRoot /../Data/domain-names.csv"
18
+ $Count = $Table.Length
20
19
20
+ write-progress " Resolving $Count domain names..."
21
+ $StopWatch = [system.diagnostics.stopwatch ]::startNew()
21
22
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 }
26
24
} 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 }
31
26
}
32
- $Count = $Table.Length
33
-
34
27
[int ]$Elapsed = $StopWatch.Elapsed.TotalSeconds
28
+
35
29
$Average = [math ]::round($Count / $Elapsed , 1 )
36
30
" $Average domains per second DNS resolution"
37
31
exit 0 # success
38
32
} catch {
39
33
" ⚠️ Error in line $ ( $_.InvocationInfo.ScriptLineNumber ) : $ ( $Error [0 ]) "
40
34
exit 1
41
- }
35
+ }
0 commit comments