Mik*_*ton 3 windows powershell
我需要在 Windows 中 ping 东西,并知道什么时候收到或错过了 ping;时间戳应反映 24 小时制(而不是 AM/PM 后缀)。
如何在 Powershell 中执行此操作?
您可以使用foreach()循环对ping 进行时间戳;Get-Date可以采用格式字符串:
C:\> powershell
PS C:\> ping.exe -t 4.2.2.2 | Foreach{"{0} - {1}" -f (Get-Date -f "yyyyMMdd HH:mm:ss"),$_}
20190601 14:33:03 -
20190601 14:33:03 - Pinging 4.2.2.2 with 32 bytes of data:
20190601 14:33:03 - Reply from 4.2.2.2: bytes=32 time=70ms TTL=123
20190601 14:33:04 - Reply from 4.2.2.2: bytes=32 time=71ms TTL=123
20190601 14:33:05 - Reply from 4.2.2.2: bytes=32 time=70ms TTL=123
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2258 次 |
| 最近记录: |