@ -931,27 +931,50 @@ if ($mirrors_response.StatusCode -eq 200) {
$hostname = $uri.Host
$dict_mirrors[$hostname] = @{}
$dict_mirrors[$hostname][" uri " ] = $mirror
$dict_mirrors[$hostname][" latency " ] = 888888 ;#default
$host_list += $hostname
#write-host " Host name: $hostname "
}
#write-host " dict: $($dict_mirrors | out-String) "
write-host " host_list: $host_list "
$test_results = Test-Connection -TargetName $host_list -Count 1 -Ipv4 -Detailed -TcpPort 443 -Quiet
for ($i = 0; $i -lt $test_results.Count; $i++) {
$result = $test_results[$i]
if ($result) {
$targethost = $result.Target
if ($result.Status - e q " S u c c e s s " ) {
$dict_mirrors[$targethost][" latency " ] = $result.Latency
if ($PSVersionTable.PSEdition - e q " D e s k t o p " ) {
#powershell.exe
#we seem to need -ErrorAction Ignore for bad/unresponsive host entries - but unlike with pwsh, we don't get any corresponding entry in the test_results, and -Quiet doesn't seem to give us results either REVIEW
$test_results = Test-Connection $host_list -Count 1 -ErrorAction Ignore
for ($i = 0; $i -lt $test_results.Count; $i++) {
$result = $test_results[$i]
if ($result) {
$targethost = $result.Address
if ($result.StatusCode - e q 0 ) {
$dict_mirrors[$targethost][" latency " ] = $result.ResponseTime
} else {
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
#pwsh.exe
$test_results = Test-Connection -TargetName $host_list -Count 1 -Ipv4 -Detailed -TcpPort 443 -Quiet
for ($i = 0; $i -lt $test_results.Count; $i++) {
$result = $test_results[$i]
if ($result) {
$targethost = $result.Target
if ($result.Status - e q " S u c c e s s " ) {
$dict_mirrors[$targethost][" latency " ] = $result.Latency
} else {
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
}
}
}
$list_mirror_dicts = @()
#write-host " dict tested: $($dict_mirrors | Out-String) "
foreach ($key in $dict_mirrors.Keys) {