Improved check-dns-resolution.ps1

This commit is contained in:
Markus Fleschutz 2021-03-29 16:34:51 +02:00
parent dbea806772
commit c297f70046

View File

@ -5,27 +5,23 @@
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
Set-StrictMode -Version Latest
$PathToRepo = "$PSScriptRoot/.."
try {
$StartTime = Get-Date
write-progress "Reading Data/domain-names.csv..."
$PathToRepo = "$PSScriptRoot/.."
$Table = import-csv "$PathToRepo/Data/domain-names.csv"
foreach($Row in $Table) {
$Domain = $Row.Domain
write-progress "Resolving $Domain..."
$Ignore = nslookup $Domain
write-progress "Resolving $($Row.Domain) ..."
$Ignore = nslookup $Row.Domain
}
$Count = $Table.Length
$StopTime = Get-Date
$TimeInterval = New-Timespan -start $StartTime -end $StopTime
write-host -foregroundColor green "OK - resolved $Count domain names in $TimeInterval seconds"
write-host -foregroundColor green "OK - resolved $Count domain names in $($TimeInterval.seconds) seconds"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"