Find Driver Version

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of MoA MoA 1 year, 10 months ago.

  • Author
    Posts
  • #26982
    Profile photo of MoA
    MoA
    Participant

    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

  • #27139
    Profile photo of Tim Pringle
    Tim Pringle
    Participant

    Hi Moa,

    Take a look at Get-WindowsDriver for this.

    Import-Module -Name Dism
    Get-WindowsDriver -All -Online
    
  • #27144
    Profile photo of Vern Anderson
    Vern Anderson
    Participant

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

  • #27273
    Profile photo of MoA
    MoA
    Participant

    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!

  • #27347
    Profile photo of MoA
    MoA
    Participant

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

You must be logged in to reply to this topic.