敢说敢作敢为, 无怨无恨无悔。这篇文章主要讲述PowerShell Where-Object 筛选出包含指定内容的行相关的知识,希望能为你提供帮助。
环境配置说明
- Windows 21H1
- PSVersion 5.1.19041.1320
示例
第一种写法
PS C:\\Users\\admin>
Get-Process | Where-Object -FilterScript {$_.ProcessName -eq "svchost"}HandlesNPM(K)PM(K)WS(K)CPU(s)IdSI ProcessName
--------------------------------- -----------
219132880125163640 svchost
1237219728269607760 svchost
21812230094968200 svchost
223122904117528440 svchost
1111177500142808960 svchost
27911232879569440 svchost
23091876111449960 svchost
3891758321473211000 svchost
16871488568011200 svchost
2481332241400811360 svchost
40913146481470411800 svchost
243102464958812480 svchost
2291224161137612800 svchost
136203908606812880 svchost
18312114161816814080 svchost
12381408660814320 svchost
43292892691614520 svchost
2251228481391214680 svchost
20271244547214840 svchost
218101968719214920 svchost
10971252487216280 svchost
168121784725216640 svchost
17491732744817160 svchost
145101876841617320 svchost
3911541241111217480 svchost
3461328961378018320 svchost
271143196810019160 svchost
13371288587219240 svchost
127101492586819320 svchost
378142316889619400 svchost
389122780939620280 svchost
1971221601206420360 svchost
16991788702821360 svchost
40731102521486022160 svchost
186112012774422480 svchost
199111876755223720 svchost
19981608702823840 svchost
6112688121602026360 svchost
51424182642706426440 svchost
32518272483148026560 svchost
4011697722008026960 svchost
215122504998827840 svchost
12571244506027960 svchost
3691727801033628200 svchost
3881945962079628720 svchost
10371244494429280 svchost
3551450801339630560 svchost
195112440837631120 svchost
295155712195842.0832441 svchost
525248436699801.3934001 svchost
2731230281632036840 svchost
3862266922728437960 svchost
266162800899638920 svchost
16891800728840080 svchost
2811742281819242400 svchost
3181941881704043640 svchost
319163956365681.2351361 svchost
157101712748851680 svchost
881991836967616052480 svchost
536265612221960.4155761 svchost
54120141841987656840 svchost
220132592880863400 svchost
48719215042410067400 svchost
187101880738467720 svchost
232152116701670560 svchost
138915401000475160 svchost
12081548704488600 svchost
第二种写法
PS C:\\Users\\admin>
Get-Process | Where ProcessName -eq svchostHandlesNPM(K)PM(K)WS(K)CPU(s)IdSI ProcessName
--------------------------------- -----------
219132880117643640 svchost
1244219880263767760 svchost
21812230086768200 svchost
223122980113568440 svchost
1120187644138128960 svchost
27811233670969440 svchost
23691876104929960 svchost
3991761241214411000 svchost
16871488484411200 svchost
2481332241326011360 svchost
40813144641348011800 svchost
247102612903212480 svchost
2291224161054812800 svchost
137203900529212880 svchost
18913117401696014080 svchost
12381408597614320 svchost
43292892624014520 svchost
2251229121347614680 svchost
20471244484814840 svchost
222102124665614920 svchost
10971252426016280 svchost
168121784649616640 svchost
17491732676417160 svchost
14591728769617320 svchost
3911541201035617480 svchost
3461328961274818320 svchost
278143312765619160 svchost
13371288517619240 svchost
127101492535619320 svchost
378142320819619400 svchost
389122860877620280 svchost
1971221841199220360 svchost
16791808655221360 svchost
4103299681352022160 svchost
186112008700822480 svchost
199111876688023720 svchost
22381616631623840 svchost
6052686721552826360 svchost
51424183362570026440 svchost
33118271682402026560 svchost
42717104521980826960 svchost
215122516941227840 svchost
12571244430027960 svchost
369172780912428200 svchost
3881945882062028720 svchost
10371244428029280 svchost
12881444665630520 svchost
3581451601324030560 svchost
195112440771631120 svchost
299155848190562.9132441 svchost
525238348690521.4834001 svchost
2731231001606836840 svchost
3802165722562037960 svchost
266162800825638920 svchost
16891800658840080 svchost
2811742281739242400 svchost
3181941881634043640 svchost
336164160357481.6751361 svchost
157101712674051680 svchost
747981827326006052480 svchost
536265612212600.4155761 svchost
54721142441967256840 svchost
220132592803263400 svchost
48719215562323267400 svchost
187101880672067720 svchost
12081528749669680 svchost
232152120639670560 svchost
13891540935275160 svchost
这两种写法在get-help Where-Object -full中有提到,可以试着阅读英文手册。
学习资料
- PowerShell 版本 + 工具
- PowerShell/PowerShell
- 51CTO社区
【PowerShell Where-Object 筛选出包含指定内容的行】感恩曾经帮助过 师万物 的人。
学有余力的话,可以了解具有开源、跨平台特性的Powershell Core。
欢迎关注公众号:悟为生心
推荐阅读
- PowerShell Get-NetAdapter 查看网络适配器的参数
- #yyds干货盘点#iptables防火墙
- 01 局域网yum 源仓库的安装
- PowerShell Get-PSRepository 查看存储库信息
- #yyds干货盘点#linux命令 –MAKEDEV 建立设备
- #yyds干货盘点#路由表的构成详解
- PowerShell KB MB GB TB PB在powershell的显示
- Flutter 专题30 图解自定义底部状态栏 ACEBottomNavigationBar #yyds干货盘点#
- MySQL optimizer_trace的用法