Windows 如何将ping结果与ttl进行比较

Windows 如何将ping结果与ttl进行比较,windows,powershell,batch-file,cmd,Windows,Powershell,Batch File,Cmd,我只想在ping中显示TTL在100-225之间的结果 Pinging x.x.x.x with 32 bytes of da Reply from x.x.x.x: bytes=32 time=124ms TTL=128 Reply from x.x.x.x: bytes=32 time=148ms TTL=64 Reply from x.x.x.x: bytes=32 time=127ms TTL=64 Reply from x.x.x.x: bytes=32 time=140ms TTL=

我只想在ping中显示TTL在100-225之间的结果

Pinging x.x.x.x with 32 bytes of da
Reply from x.x.x.x: bytes=32 time=124ms TTL=128
Reply from x.x.x.x: bytes=32 time=148ms TTL=64
Reply from x.x.x.x: bytes=32 time=127ms TTL=64
Reply from x.x.x.x: bytes=32 time=140ms TTL=128

谢谢

您可以使用
测试连接
cmdlet来执行此操作。例如:

Test-Connection <TargetServerName> | 
    Where-Object {$_.TimeToLive -ge 100 -and $_.TimeToLive -le 225} |
        Format-Table __Server, Address, TimeToLive -AutoSize
测试连接|
其中对象{$\.TimeToLive-ge100-和$\.TimeToLive-le225}|
格式表\uuuu服务器、地址、TimeToLive-自动调整大小

带有批处理文件的选项

@echo off
setlocal enabledelayedexpansion

for /F "delims=" %%G in ('ping 10.28.2.38 ^|findstr /B /C:"Reply from"') do (
    set "ping=%%G"
    set "TTL=!ping:*TTL=!"
    SET "TTL=!TTL:~1!"
    IF !TTL! GEQ 100 IF !TTL! LEQ 225 echo %%G
)

那findstr呢?“我想要”不是一个问题,所以请具体点!在这里阅读并学习!请注意StackOverflow不是免费的代码编写服务!作为一个起点,看一看和。。。