1

get-wmiobject -class Win32_SCSIControllerDevice を使用して、Antecedent および Dependent デバイスの 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

これらの 2 つのコマンドをネストして、以下の例のような結果を得るにはどうすればよいですか?

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

さまざまなフォーマットを試してみましたが、サインラインにはありません。

4

1 に答える 1

0

Select-Object (alias select) コマンドレットを使用してプロパティを選択するだけです。

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
于 2016-05-13T15:23:13.820 に答える