You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell 5.1中Test-Connection结合Select-Object筛选列及属性查询

解决Test-Connection结果列筛选与属性文档问题

筛选指定列的Select-Object语法

要只保留Source、Destination、Bytes和Time(ms)列,直接在Test-Connection后通过管道调用Select-Object,指定需要的属性即可:

Test-Connection -Source $source -Destination $remoteHost | Select-Object Source, Destination, Bytes, 'Time(ms)'

注意Time(ms)因为名称包含特殊字符,必须用单引号包裹,防止PowerShell解析时出错。

查看返回对象的属性文档

在PowerShell 5.1里,不用跳转到外部网站,直接用内置命令就能获取属性信息:

  • 用Get-Member查看实时对象属性:
    执行以下命令,会列出Test-Connection返回对象(类型为Win32_PingStatus)的所有属性、方法细节:
    Test-Connection -Source $source -Destination $remoteHost | Get-Member
    
  • 用Get-Help查看官方文档:
    运行下面的命令,在输出的OUTPUTS章节中,会明确说明返回对象的类型及对应属性的官方解释:
    Get-Help Test-Connection -Full
    

内容的提问来源于stack exchange,提问作者user945761

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 22:38:09