搞个Powershell 的给你玩玩。自己美化。或者??。- $IP =(gc IP.txt -ReadCount 0 -enc Default) | %{
- $ref = $_.Trim() -split '\s+';
- $index++;
- [PSCustomObject]@{
- index = $index;
- name = $ref[0];
- ip = $ref[1];
- }
- }
-
- $Lost = $offLine = $Latency = @();
- foreach($i in $IP)
- {
- Write-Host "正在测试连接 $($i.name) =$($i.ip)......" -NoNewline;
- $n =Test-Connection -Computer $i.ip -Count 10 -ErrorAction 'SilentlyContinue';
- $v =$n.ResponseTime | measure -Average -Maximum;
- if ($n.count -le 0) {
- $offLine +=$i.index.ToString()+' '+$i.name+' '+$i.ip;
- Write-Host '失败' -fore red;
- } else {
- if ($n.Count -lt 10) {
- $Lost +=$i.index.ToString()+' '+$i.name+' '+$i.ip+' '+(10-$n.Count).ToString()+' '+$v.Average+'ms';
- }
- foreach($a in $n.ResponseTime)
- {
- if ($a -gt 20){
- $Latency +=$i.index.ToString()+' '+$i.name+' '+$i.ip+' '+(10-$n.Count).ToString()+' '+$v.Maximum+'ms';
- break;
- }
- }
- Write-Host '完成' -fore Green
- }
- }
-
- if ($Lost) { sc ".\Lost.txt" -Value $Lost -Force -enc Default };
- if ($offLine) { sc ".\offLine.txt" -Value $offLine -Force -enc Default };
- if ($Latency) { sc ".\Latency.txt" -Value $Latency -Force -enc Default };
复制代码
|