forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-dns.ps1
executable file
·41 lines (37 loc) · 1.01 KB
/
check-dns.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
.SYNOPSIS
Checks the DNS resolution
.DESCRIPTION
This PowerShell script checks the DNS resolution with frequently used domain names.
.EXAMPLE
PS> ./check-dns
11.8 domains per second DNS resolution
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
write-progress "Reading 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
[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
}