如何使用 PowerShell (winpe) 获取 Devcon 输出的对象?

How to get an object of Devcon output using PowerShell (winpe)?

我想 select 从 Devcon.exe 输出一个对象。

PCI\VEN_8086&DEV_2822&SUBSYS_1790103C&REV_04&11583659&0&FA
    Name: Intel(R) Chipset SATA/PCIe RST Premium Controller
Driver node #0:
    Inf file is C:\Windows\INF\iastorav.inf
    Inf section is iaStorAVC_inst
    Driver description is Intel Chipset SATA RAID Controller
    Manufacturer name is Intel Corporation
    Provider name is Intel Corporation
    Driver date is 2/7/2018
    Driver version is 15.44.0.1010
    Driver node rank is 16711683
    Driver node flags are 00102044
        Inf is digitally signed
Driver node #1:
    Inf file is C:\Windows\INF\oem9.inf
    Inf section is iaStorAC_inst_8
    Driver description is Intel(R) Chipset SATA/PCIe RST Premium Controller
    Manufacturer name is Intel Corporation
    Provider name is Intel Corporation
    Driver date is 5/9/2019
    Driver version is 17.5.0.1017
    Driver node rank is 8388611
    Driver node flags are 00003044
        Inf is digitally signed

我想通过映射 Driver description 来获得 Driver version 。 我试过这种方法,但我无法获取驱动程序版本。

 $hardwareid = "PCI\VEN_8086&DEV_2822&SUBSYS_1790103C&REV_04"
 $Description = "Intel(R) Chipset SATA/PCIe RST Premium Controller"
 $DrNode = & .\devcon.exe /drivernodes "$hardwareid"             
 $Ver = $DrNode | Where-Object {$_ -like "*$Description*"} | Select-Object Driver version

请大家出出主意。非常感谢!

问题是 devcon 输出文本。使用 WMI 做这样的事情怎么样?

Get-WmiObject Win32_PnPSignedDriver | 
  where description -match 'apple solid state drive device' |
  select driverversion

driverversion
-------------
6.0.6400.0

好的,这在 winpe 中对我有用。我在这里得到它:https://superuser.com/questions/1438704/how-to-find-driver-version-for-all-devices-through-wmi/1438715#1438715 它从文件信息中获取驱动程序的版本。

get-wmiobject Win32_SystemDriver | select DisplayName,@{n="version";
  e={(get-item $_.pathname).VersionInfo.FileVersion}} | 
  where displayname -match 'apple solid state drive'

DisplayName                    version
-----------                    -------
Apple Solid State Drive Device 6.0.6400.0