[英]Get-WmiObject not showing desired results while filtering for PNPDeviceID
[英]How can I get PnpDeviceId of Antecedent and Dependent device using get-wmiobject in single output?
我想在單個輸出中使用get-wmiobject -class Win32_SCSIControllerDevice(例如在表中)獲取前導和從屬設備的PnpDeviceId。 我弄清楚我能做到:
Get-WmiObject -class Win32_SCSIControllerDevice | ForEach-Object { [WMI]$_.Antecedent} | Format-Table PnpDeviceId
和
Get-WmiObject -class Win32_SCSIControllerDevice | ForEach-Object { [WMI]$_.Dependent} | Format-Table PnpDeviceId
如何嵌套這兩個命令以獲得結果如下例所示?
PnpDeviceId PnpDeviceId
----------- -----------
PnpDeviceIdAntecedentDevice PnpDeviceIdDependentDevice
PnpDeviceIdAntecedentDevice PnpDeviceIdDependentDevice
PnpDeviceIdAntecedentDevice PnpDeviceIdDependentDevice
編輯:
運用
Get-WmiObject -class Win32_SCSIControllerDevice | ForEach-Object { [WMI]$_.Antecedent, [WMI]$_.Dependent } | Format-Table PnpDeviceId
我有:
PnpDeviceId
-----------
PnpDeviceIdAntecedentDevice
PnpDeviceIdDependentDevice
PnpDeviceIdAntecedentDevice
PnpDeviceIdDependentDevice
PnpDeviceIdAntecedentDevice
PnpDeviceIdDependentDevice
我嘗試了不同的格式,但沒有符號線。
只需使用Select-Object (別名select
)cmdlet選擇屬性:
Get-WmiObject -class Win32_SCSIControllerDevice | select Antecedent, Dependent
編輯:
如果要選擇嵌套屬性,可以使用自定義select語句:
Get-WmiObject -class Win32_SCSIControllerDevice | Select @{e={([WMI]$_.Antecedent).PNPDeviceID}; l='Antecedent PNPDeviceID'}, @{e={([WMI]$_.Dependent).PNPDeviceID}; l='Dependent PNPDeviceID'}
輸出:
Antecedent PNPDeviceID Dependent PNPDeviceID
---------------------- ---------------------
PCI\VEN_8086&DEV_282A&SUBSYS_05351028&REV_04\3&11583659&0&FA SCSI\DISK&VEN_LITEONIT&PROD_LCT-256M3S\4&62C5D10&0&000000
PCI\VEN_8086&DEV_282A&SUBSYS_05351028&REV_04\3&11583659&0&FA SCSI\CDROM&VEN_TSSTCORP&PROD_DVD-ROM_TS-U333B\4&62C5D10&0&010000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.