Author Posts

June 30, 2015 at 2:52 pm

I have this input to work with. Goal is to find the file version and driver version.
I am able to find the file versions of each file.

How do I find the driver version, given just that input.
Any cmdlets that uses hardwareID or Driver's full name to extract the information?

USB\ROOT_HUB20\4&361B340A&0
    Name: USB Root Hub
    Driver installed from C:\windows\INF\usbport.inf [ROOTHUB.Dev]. 2 file(s) used by driver:
        C:\windows\system32\drivers\usbhub.sys
        C:\windows\system32\drivers\usbd.sys
ACPI\PNP0C09\1
USB\ROOT_HUB20\4&361B340A&1
    Name: USB Root Hub
    Driver installed from C:\windows\INF\usbport.inf [ROOTHUB.Dev]. 2 file(s) used by driver:
        C:\windows\system32\drivers\usbhub.sys
        C:\windows\system32\drivers\usbd.sys
ACPI\PNP0C09\2
USB\ROOT_HUB20\4&361B340A&2
    Driver installed from C:\windows\INF\cmbatt.inf [CmBatt_Inst]. 2 file(s) used by driver:
        C:\windows\system32\DRIVERS\CmBatt.sys
        C:\windows\system32\DRIVERS\battc.sys
ACPI\PNP0C0A\2
    Name: Microsoft ACPI-Compliant Control Method Battery
    Driver installed from C:\windows\INF\cmbatt.inf [CmBatt_Inst]. 2 file(s) used by driver:
        C:\windows\system32\DRIVERS\CmBatt.sys
        C:\windows\system32\DRIVERS\battc.sys
.
.
.
.
.
.
.

I am using this script to parse the text file:

(Get-Content C:\Path\To\File.txt) -join "`r`n" -Split "(?m)^(?=\S)" |
    Where{$_} | 
    ForEach{
        Clear-Variable Files,Driver,Name,HardwareID
        $Files = @()
        $HardwareID = ($_ -split "`r`n")[0].trim()
        Switch -regex ($_ -split "`r`n"){
            "^\s+Name:" {$Name = ($_ -split ':',2)[-1].trim();Continue}
            "^\s+.:\\" {$Files += $_.trim();continue}
            "^\s+Driver" {$Driver = [RegEx]::Matches($_,"(?< =Driver installed from )(.+?)(?= \[)").value;continue}
        }
        [PSCustomObject]@{'HardwareID' = $HardwareID;'Name' = $Name; 'Driver' = $Driver; 'Files' = $Files}
    }

And the output looks like this:

HardwareID                  Name                                            Files                                  FileVersion                             
----------                  ----                                            -----                                  -----------                             
USB\ROOT_HUB20\4&361B340A&0 USB Root Hub                                    C:\windows\INF\usbport.inf                                                     
USB\ROOT_HUB20\4&361B340A&0 USB Root Hub                                    C:\windows\system32\drivers\usbhub.sys 6.3.9600.17238 (winblue_gdr.140723-2018)
USB\ROOT_HUB20\4&361B340A&0 USB Root Hub                                    C:\windows\system32\drivers\usbd.sys   6.3.9600.17195 (winblue_gdr.140530-1506)
ACPI\PNP0C09\1                                                                                                                                             
USB\ROOT_HUB20\4&361B340A&1 USB Root Hub                                    C:\windows\INF\usbport.inf                                                     
USB\ROOT_HUB20\4&361B340A&1 USB Root Hub                                    C:\windows\system32\drivers\usbhub.sys 6.3.9600.17238 (winblue_gdr.140723-2018)
USB\ROOT_HUB20\4&361B340A&1 USB Root Hub                                    C:\windows\system32\drivers\usbd.sys   6.3.9600.17195 (winblue_gdr.140530-1506)

I would like to add an extra column that list the driver version?
I guess I can run another command to find all of the drivers and their version, but is there a way to use information in this same file and user PowerShell command to find it's version?

Thank you

July 5, 2015 at 12:02 am

Hi Moa,

Take a look at Get-WindowsDriver for this.

Import-Module -Name Dism
Get-WindowsDriver -All -Online

July 5, 2015 at 5:29 am

Get-WmiObject -Query "SELECT Description,DriverVersion FROM Win32_PnPSignedDriver" | Where-Object {$_.Description} | Format-Table Description,DriverVersion

July 7, 2015 at 8:30 am

Thank you for your replies. Above comments are useful; however, I am trying to use the information in the text file to get the version.
For instance, use INF file and parse out the driver version in it and display it next to Name column.
Thank you!

July 9, 2015 at 7:34 am

I was able to parse the INF file and get the driver version from there.