Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions SystemTester.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -575,36 +575,33 @@ function Test-NetworkSpeed {

function Test-NetworkLatency {
Write-Host "`n=== Network Latency (Test-NetConnection & PsPing) ===" -ForegroundColor Green

$targetHost = "8.8.8.8"
$lines = @("Target: $($targetHost):$targetPort")
$lines = @("Target: $targetHost")
$status = "SUCCESS"

# Built-in Test-NetConnection results
# Built-in Test-NetConnection results (ICMP only)
try {
$tnc = Test-NetConnection -ComputerName $targetHost -Port $targetPort -InformationLevel Detailed
$tnc = Test-NetConnection -ComputerName $targetHost -InformationLevel Detailed
if ($tnc) {
$lines += "Test-NetConnection:"
$lines += " Ping Succeeded: $($tnc.PingSucceeded)"
if ($tnc.PingReplyDetails) {
$lines += " Ping RTT: $($tnc.PingReplyDetails.RoundtripTime) ms"
}
$lines += " TCP Succeeded: $($tnc.TcpTestSucceeded)"
}
} catch {
$status = "FAILED"
$lines += "Test-NetConnection: Failed - $($_.Exception.Message)"
}

# Sysinternals PsPing results
# Sysinternals PsPing results (ICMP only)
try {
$pspingPath = Join-Path $SysinternalsPath "psping.exe"
if (Test-Path $pspingPath) {
$pspingArgs = @("-accepteula", "-n", "5", "{0}:{1}" -f $targetHost, $targetPort)
$pspingArgs = @("-accepteula", "-n", "5", $targetHost)
Write-Host "Running PsPing latency test..." -ForegroundColor Yellow
$pspingOutput = & $pspingPath $pspingArgs 2>&1 | Out-String
$lines += "PsPing Summary:"

$average = $null
$minimum = $null
$maximum = $null
Expand All @@ -615,7 +612,6 @@ function Test-NetworkLatency {
$average = [double]$matches[3]
}
}

if ($null -ne $average) {
$lines += " Min: $minimum ms"
$lines += " Max: $maximum ms"
Expand All @@ -630,7 +626,7 @@ function Test-NetworkLatency {
$status = "FAILED"
$lines += "PsPing Summary: Failed - $($_.Exception.Message)"
}

$script:TestResults += @{
Tool="Network-Latency"; Description="Connectivity latency tests"
Status=$status; Output=($lines -join "`n"); Duration=0
Expand Down
Loading