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