0

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
Imsa
  • 881
  • 1
  • 13
  • 35

3 Answers3

2

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.

Narcis
  • 131
  • 6
  • I like this solution, for those having trouble to execute it (`execution of scripts is disabled on this system`), here is the answer http://stackoverflow.com/a/4038991/ – feelthhis Apr 13 '17 at 14:48
1

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.
Imsa
  • 881
  • 1
  • 13
  • 35
0
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.

Kiran
  • 2,643
  • 2
  • 14
  • 19
  • Thank you! But I am trying to list ALL of the file associated with the driver. – Imsa Jun 25 '15 at 23:49
  • ok i guess you will have to use devcon and parse its output using regex which will take some doing. Or export all the drivers into a temp folder and then go into that folder and make a listing of each driver along with its files used – Kiran Jun 26 '15 at 03:40
  • How can I export/backup all of the drivers installed to a folder along with their files? Thank you! – Imsa Jun 26 '15 at 15:42