How can you write a script in PowerShell that displays the total pinging time of a computer (for example, 192.168.10.10) on the network?
2 answers
But why make a bike?
[int]$t = $null (Test-Connection 192.168.10.10).ResponseTime | foreach { $t += $_ } Write-Host "Ping time: $t ms" |
[cmdletbinding()] Param ( [Parameter (Mandatory=$true, helpmessage="host or IP")] [string]$in_host, [Parameter (Mandatory=$true)] [int]$count) $rt=0 for($i=0;$i -lt $count;$i++) { $info=Get-WmiObject -Class win32_pingstatus -f "Address='$in_host'" write-host "Адрес:" $in_host "Время:" $info.responsetime "ms" "Статус" $info.StatusCode "Время жизни" $info.TimeToLive $rt+=$info.ResponseTime } Write-Host "Время пингования:" $rt "ms" |