2016-05-13 1 views
1

get-wmiobject -class Win32_SCSIControllerDeviceを単一の出力(たとえばテーブル内)で使用して、AntecedentおよびDependentデバイスのPnpDeviceIdを取得したいとします。 私は私が行うことができますそれを把握:1出力でget-wmiobjectを使用して、先行デバイスと従属デバイスの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 

EDIT:

Get-WmiObject -class Win32_SCSIControllerDevice | ForEach-Object { [WMI]$_.Antecedent, [WMI]$_.Dependent } | Format-Table PnpDeviceId 

を使用して私が得た:

PnpDeviceId    
-----------     
PnpDeviceIdAntecedentDevice 
PnpDeviceIdDependentDevice 
PnpDeviceIdAntecedentDevice 
PnpDeviceIdDependentDevice 
PnpDeviceIdAntecedentDevice 
PnpDeviceIdDependentDevice 

私は、異なるフォーマットを試したがACシングルラインではありません。

Get-WmiObject -class Win32_SCSIControllerDevice | select Antecedent, Dependent 

編集:あなたは、ネストされたプロパティを選択したい場合は

は、カスタムselect文を使用することができます。

答えて

0

だけSelect-Object(別名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 
+0

これはパス全体を選択するため、DeviceIdの後ろにあるものだけが必要です。私は後でそれを解析することができますが、私は良いとクリーンな出力を持っている方法を探しています – kendzi

+0

さて、私はカスタムの選択例を追加しました。 –

+0

助けてくれてありがとう、これは私にとって素晴らしい作品です。 – kendzi

関連する問題