[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
搞个Powershell 的给你玩玩。自己美化。或者??。
  1. $IP =(gc IP.txt -ReadCount 0 -enc Default) | %{
  2. $ref = $_.Trim() -split '\s+';
  3. $index++;
  4. [PSCustomObject]@{
  5. index = $index;
  6. name = $ref[0];
  7. ip = $ref[1];
  8. }
  9. }
  10. $Lost = $offLine = $Latency = @();
  11. foreach($i in $IP)
  12. {
  13. Write-Host "正在测试连接 $($i.name) =$($i.ip)......" -NoNewline;
  14. $n =Test-Connection -Computer $i.ip -Count 10 -ErrorAction 'SilentlyContinue';
  15. $v =$n.ResponseTime | measure -Average -Maximum;
  16. if ($n.count -le 0) {
  17. $offLine +=$i.index.ToString()+' '+$i.name+' '+$i.ip;
  18. Write-Host '失败' -fore red;
  19. } else {
  20. if ($n.Count -lt 10) {
  21. $Lost +=$i.index.ToString()+' '+$i.name+' '+$i.ip+' '+(10-$n.Count).ToString()+' '+$v.Average+'ms';
  22. }
  23. foreach($a in $n.ResponseTime)
  24. {
  25. if ($a -gt 20){
  26. $Latency +=$i.index.ToString()+' '+$i.name+' '+$i.ip+' '+(10-$n.Count).ToString()+' '+$v.Maximum+'ms';
  27. break;
  28. }
  29. }
  30. Write-Host '完成' -fore Green
  31. }
  32. }
  33. if ($Lost) { sc ".\Lost.txt" -Value $Lost -Force -enc Default };
  34. if ($offLine) { sc ".\offLine.txt" -Value $offLine -Force -enc Default };
  35. if ($Latency) { sc ".\Latency.txt" -Value $Latency -Force -enc Default };
复制代码

TOP

回复 5# bigjohn

这个报错是 脚本 找不到 IP.txt 在哪里 ,导致后面的参数值为空值。
请确保你的 系统已正常激活 POWERSHELL。 偶们一般不用 ISE. 你现在用的是ISE。那就说一下ISE操作。【打开 ISE ,然后在下面的蓝底命令行窗口 输入中括号内的具体内容:[cd "你入IP.txt的文件夹完整路径“]。如 cd c:\temp\test 回车。再把脚本内容粘贴进去,回车运行就可以了。

当然你也可以把脚本中的 IP.TXT 改文件的绝对路径。 以及最后三行中的 .\xxx.txt 输出文件 也改成绝对路径。然后就是直接复制粘贴运行。

TOP

回复 9# bigjohn


    你用的是什么脚本?什么@???

TOP

返回列表