mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-17 07:28:18 +02:00
Update check-dns.ps1
This commit is contained in:
parent
90e5fc9398
commit
7dc18b5b00
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the DNS resolution
|
Check DNS resolution
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script measures the DNS resolution speed by using 200 popular domains.
|
This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-dns
|
PS> ./check-dns
|
||||||
✅ DNS resolution is 440.5 domains per second
|
✅ DNS resolves 156.5 domains per second
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -14,24 +14,24 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Progress "⏳ Resolving 200 popular domains..."
|
Write-Progress "⏳ Resolving 200 popular domains..."
|
||||||
$Table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
|
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
|
||||||
$NumRows = $Table.Length
|
$numRows = $table.Length
|
||||||
|
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
foreach($Row in $Table){$nop=dig $Row.Domain +short}
|
foreach($row in $table){$nop=dig $row.Domain +short}
|
||||||
} else {
|
} else {
|
||||||
foreach($Row in $Table){$nop=Resolve-DNSName $Row.Domain}
|
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||||
}
|
}
|
||||||
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
|
|
||||||
$Average = [math]::round($NumRows / $Elapsed, 1)
|
Write-Progress -completed "."
|
||||||
if ($Average -gt 10.0) {
|
$average = [math]::round($numRows / $elapsed, 1)
|
||||||
"✅ DNS resolution is $Average domains per second"
|
if ($average -gt 10.0) {
|
||||||
|
"✅ DNS resolves $average domains per second"
|
||||||
} else {
|
} else {
|
||||||
"⚠️ DNS resolution is $Average domains per second only!"
|
"⚠️ DNS resolves $average domains per second only!"
|
||||||
}
|
}
|
||||||
Write-Progress -completed "Done."
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user