mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-26 00:28:53 +01:00
39 lines
961 B
PowerShell
Executable File
39 lines
961 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
check-dns-resolution.ps1
|
|
.DESCRIPTION
|
|
Checks the DNS resolution with frequently used domain names.
|
|
.EXAMPLE
|
|
PS> .\check-dns-resolution.ps1
|
|
.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)
|
|
"✔️ $Average domains/s ($Count domains resolved in $Elapsed sec)"
|
|
exit 0
|
|
} catch {
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|