I am planning to use test-connection to test link quality of devices. I wrote the following but I was wondering if there was a more accurate way. I just created an array of numbers to test my logic out on.
#for this example I just created an array of numbers to play with
$pingtimes = 1,12,32,23,1324,234,2,234,2,23,500,3,2,2,2,2,56,324,15
$pingtimes = $pingtimes | Sort-Object
#Get pings higher than 450ms
[array]$HighMs = $null
$HighMs += $pingtimes | ?{$_ -gt 450}
#if more than 25% of the pings are greater than 450 ms assume a connectivity issue
if($HighMs.Count -gt ([math]::Round(($pingtimes.Count * .25),0)))
{
"connectivity issue"
}
else
{"no connectivity issue"
}