【发布时间】:2019-12-21 19:19:53
【问题描述】:
有一个命令执行并给我以下输出
Customer ID Client Name Computer Name Computer Brand
123 user1 127.0.0.1 lenovo
1 user2 127.0.0.2 apple
86 user3 127.0.0.1 dell
21 user4 127.0.0.4 apple
我想获取使用Computer Brandapple 的用户的Customer ID。输出应该如下,以便我可以对这些 ID 进行进一步的操作:
1
21
我尝试使用以下命令首先选择带有“apple”的用户:
$output | Select-String -pattern 'apple'
但是它只会打印带有“apple”的用户,而不是第一行,这让我很难进一步处理。
更新
我不知道以下是否有帮助。
PS> $output.GetType();
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
【问题讨论】:
标签: powershell