Update check-dns.ps1 and check-ping.ps1

This commit is contained in:
Markus Fleschutz 2023-03-20 11:06:45 +01:00
parent 7dc18b5b00
commit 91526bd1ee
2 changed files with 5 additions and 4 deletions

View File

@ -13,7 +13,7 @@
#> #>
try { try {
Write-Progress "⏳ Resolving 200 popular domains..." Write-Progress "⏳ Resolving 200 popular domain names..."
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv" $table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
$numRows = $table.Length $numRows = $table.Length

View File

@ -7,7 +7,7 @@
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com) Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com)
.EXAMPLE .EXAMPLE
PS> ./check-ping PS> ./check-ping
Ping latency is 13ms...109ms, 25ms average. Ping latency is 13ms...109ms with 25ms average.
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -20,7 +20,6 @@ try {
Write-Progress "⏳ Sending a ping to 9 popular hosts..." Write-Progress "⏳ Sending a ping to 9 popular hosts..."
$HostsArray = $hosts.Split(",") $HostsArray = $hosts.Split(",")
$Pings = Test-Connection -computerName $HostsArray -count 1 $Pings = Test-Connection -computerName $HostsArray -count 1
Write-Progress -Completed "."
[int]$Min = 9999999 [int]$Min = 9999999
[int]$Max = [int]$Avg = 0 [int]$Max = [int]$Avg = 0
@ -31,7 +30,9 @@ try {
$Avg += $Latency $Avg += $Latency
} }
$Avg /= $Pings.count $Avg /= $Pings.count
Write-Host "✅ Ping latency is $($Min)ms...$($Max)ms, $($Avg)ms average"
Write-Progress -Completed "."
Write-Host "✅ Ping latency is $($Min)ms...$($Max)ms with $($Avg)ms average"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"