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

如何无需文件中转查询PowerShell cmdlet的文本输出内容?

解决PowerShell Cmdlet输出属性的便捷搜索问题

方法1:转换为字符串流后搜索

直接将Get-ComputerInfo的输出拆分为字符串行,再用Select-String过滤内容,就能匹配到目标属性和对应值:

Get-ComputerInfo | Out-String -Stream | Select-String 'Intel'

Out-String -Stream会把对象的格式化输出拆分成单行字符串,让Select-String可以正常逐行匹配,比如查找Intel处理器型号时,直接返回对应的属性行。

方法2:直接访问对象属性(精准高效)

如果想跳过文本处理,直接操作对象属性更高效:

  • 先列出所有属性名,快速定位目标:
Get-ComputerInfo | Get-Member -MemberType NoteProperty | Select-Object Name
  • 找到属性后直接调用,比如处理器相关属性在CsProcessors集合里,筛选Intel型号:
(Get-ComputerInfo).CsProcessors | Where-Object Manufacturer -eq 'Intel' | Select-Object Name

方法3:格式化后再搜索

如果习惯Property: Value的显示格式,用Format-List强制格式化后再转字符串流:

Get-ComputerInfo | Format-List * | Out-String -Stream | Select-String 'Processor'

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 00:20:33