mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
Update check-dns.ps1
This commit is contained in:
parent
09306c0156
commit
f41205c332
@ -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,29 +13,23 @@
|
||||
#>
|
||||
|
||||
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
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user