List Driver related files and their versions

5.3k views Asked by At

Is there any way or tutorials where I can:

  1. List all of the files related to the driver
  2. List File version of those file (.exe, .dll, .sys and etc.)

I am trying to compile a list of all of the drivers installed in the computer and mainly list all of the files related to the driver (exe, sys, dll and etc.) along with file version. Please see attached picture.

Link to picture:

I tried to use Wmi-Object (Powershell) and DevCon tool, but can get those files to be listed.

Using Powershell, I am able to list the driver name, but only file appears.

# Script to output all of the drivers installed in the computer

# Export all driver names to a text file
Get-WmiObject win32_SystemDriver | select name | foreach {$_.name} | Out-File C:\driverName.csv

# Read driver name from file.
$driver =  Get-Content "C:\driverName.csv"

# Get the file path of the driver
$path = (Get-WmiObject win32_SystemDriver | Where-Object name -match $driverName).PathName

# Extract information from the file path and export it to CSV
(Get-Item $path).VersionInfo  | Select FileDescription, ProductVersion, FileVersion, FileName | Export-Csv -Path C:\FileVersion.csv
3

There are 3 answers

0
Imsa On BEST ANSWER

User DevCon utility to list information about all of the drivers installed in the computer.

  1. Download DevCon package from here:
  2. Unzip the package
  3. Open CMD as Admin and change directory to unzipped folder
  4. Run devcon.exe driverfiles *
  5. It will list all of the driver installed in the computer, their hardware ids, .inf file, and all other file associated with that particular driver.
3
Kiran Reddy On
Get-WmiObject -Class Win32_SystemDriver | 
Select-Object Name,PathName,@{N='FileInfo';E={Get-Item -Path $_.pathname | Select-Object -ExpandProperty VersionInfo | Select-Object FileDescription, ProductVersion, FileVersion, FileName}}  | 
    Export-Clixml C:\temp\drivers.xml

$ImportedXML = Import-Clixml -Path C:\temp\drivers.xml

$ImportedXML | Where-Object Name -eq '3ware' | Select-Object -ExpandProperty fileinfo

since the information you are looking for is buried under a nested property you cannot export the structure to a flat file like a 'CSV' well not without some customizations. anyway the better option would be to store the output in an xml file as shown above and retrieve the information when required.

1
Narcis On

Here is a Powershell script that does exactly what is requested:

#
$hostname = $ENV:COMPUTERNAME

# Get Third Party drivers used, that are not provided by Microsoft and presumably included in the OS
$drivers = Get-WmiObject Win32_PNPSignedDriver | where {$_.DriverProviderName -ne "Microsoft"}

# Initialize the list of detected driver packages as an array
$DriverFolders = @()
foreach ($d in $drivers) {
    # We initialize the list of driver files for each driver
    $DriverFiles = @()
    # For each driver instance from WMI class Win32_PNPSignedDriver, we compose the related WMI object name from the other WMI driver class, Win32_PNPSignedDriverCIMDataFile
    $ModifiedDeviceID = $d.DeviceID -replace "\\", "\\"
    $Antecedent = "\\" + $hostname + "\ROOT\cimv2:Win32_PNPSignedDriver.DeviceID=""$ModifiedDeviceID"""
    # Get all related driver files for each driver listed in WMI class Win32_PNPSignedDriver
    $DriverFiles += Get-WmiObject Win32_PNPSignedDriverCIMDataFile | where {$_.Antecedent -eq $Antecedent}
    $DriverName = $d.DeviceName
    $DriverID = $d.DeviceID
    Write-Host "####Driver files for driver with name: $DriverName" -ForegroundColor Green
    Write-Host "and with DriverID: $DriverID" -ForegroundColor Green
    foreach ($i in $DriverFiles) {
            # We elliminate double backslashes from the file paths
            $path = $i.Dependent.Split("=")[1] -replace '\\\\', '\'
            $path2 = $path.Substring(1,$path.Length-2)
            $InfItem = Get-Item -Path $path2
            $Version = $InfItem.VersionInfo.FileVersion
            Write-Output "File: $path2"
            Write-Output "Version: $Version"
    }
    }
#

You can do much more starting from this, even extracting all driver related files from these detected as installed and used by the system.

The more complex version of the script can be found here.