mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-11 21:59:11 +02:00
Rename to check-dns.ps1
This commit is contained in:
41
Scripts/check-dns.ps1
Executable file
41
Scripts/check-dns.ps1
Executable file
@ -0,0 +1,41 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks the DNS resolution
|
||||
.DESCRIPTION
|
||||
This script checks the DNS resolution with frequently used domain names.
|
||||
.EXAMPLE
|
||||
PS> ./check-dns
|
||||
✔️ DNS resolves 11.8 domains/sec (177 domains in 15 sec)
|
||||
.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..."
|
||||
|
||||
$PathToRepo = "$PSScriptRoot/.."
|
||||
$Table = import-csv "$PathToRepo/Data/domain-names.csv"
|
||||
|
||||
foreach($Row in $Table) {
|
||||
write-progress "Resolving $($Row.Domain) ..."
|
||||
if ($IsLinux) {
|
||||
$Ignore = nslookup $Row.Domain
|
||||
} else {
|
||||
$Ignore = resolve-dnsName $Row.Domain
|
||||
}
|
||||
}
|
||||
$Count = $Table.Length
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
$Average = [math]::round($Count / $Elapsed, 1)
|
||||
$Reply = "DNS resolves $Average domains/sec ($Count in $Elapsed sec)"
|
||||
"✔️ $Reply"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Reply"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user