我正在尝试过滤 wmic 列表的结果,where-object
但不幸的是这似乎不起作用。
wmic diskdrive list brief | Where-Object -Property "Caption" -Contains "Samsung"
过滤后的结果为空,未过滤的结果是这样的:
Caption DeviceID Model Partitions Size
HGST HUH721212ALE600 \\.\PHYSICALDRIVE1 HGST HUH721212ALE600 1 12000132426240
OCZ-VERTEX3 \\.\PHYSICALDRIVE3 OCZ-VERTEX3 1 240054796800
Samsung SSD 970 EVO Plus 1TB \\.\PHYSICALDRIVE5 Samsung SSD 970 EVO Plus 1TB 4 1000202273280
ST16000NM001G-2KK103 \\.\PHYSICALDRIVE4 ST16000NM001G-2KK103 1 16000900392960
ST6000NM0024-1HT17Z \\.\PHYSICALDRIVE0 ST6000NM0024-1HT17Z 1 6001172513280
Samsung SSD 840 PRO Series \\.\PHYSICALDRIVE2 Samsung SSD 840 PRO Series 1 512105932800
如何正确过滤?
最后,我想得到DeviceID
,例如,PHYSICALDRIVE5