Skip to content

Commit

Permalink
Fix Measure-DnsResponseTime
Browse files Browse the repository at this point in the history
  • Loading branch information
SamErde committed Dec 11, 2024
1 parent 66e6a7a commit d13bd8b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions DDI/Measure-DnsServerResponse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ function Measure-DnsResponseTime {
for ($i = 0; $i -lt $QueryCount; $i++) {
Write-Host '.' -NoNewline -ForegroundColor Yellow
try {
Clear-DnsClientCache
$QueryTimes += (Measure-Command { [System.Net.Dns]::GetHostAddresses($TargetName) }).TotalMilliseconds
# $QueryTimes += (Measure-Command { Resolve-DnsName -Server $DnsServer -Name $Targetname -DnsOnly -NoHostsFile }).TotalMilliseconds
# $ResponseTime = (Get-History -Count 1).Duration.TotalMilliseconds
$QueryTimes += (Measure-Command { Resolve-DnsName -Server $DnsServer -Name $TargetName -DnsOnly -NoHostsFile }).TotalMilliseconds
} catch {
Write-Output "Failed to resolve DNS query: $_"
return
Expand All @@ -58,14 +55,14 @@ function Measure-DnsResponseTime {
Write-Host '. Done!' -ForegroundColor Green
"Times: $($QueryTimes -join ', ')" | Write-Verbose
$AverageTime = [math]::Round( ($QueryTimes | Measure-Object -Average).Average, 2 )
Write-Host "Average response time: $AverageTime ms`n" -ForegroundColor Green
Write-Host "Average response time: $AverageTime ms`n" -ForegroundColor White
$AverageTime
}

function Measure-NetworkHops {
<#
.SYNOPSIS
Measure the number of network hops and get basic traceroute details for a given server.
Measure the number of network hops and get basic trace route details for a given server.
.PARAMETER Server
The server name or IP address to measure network hops to.
Expand Down

0 comments on commit d13bd8b

Please sign in to comment.