我编写了一个名为Invoke-InstallDrivers(Link to Github)的函数,该函数用于将驱动程序文件的GUID与已安装硬件的GUID进行比较,如果安装的匹配项匹配,如果没有它将跳过的匹配项。我修改了这个函数来拉取你正在查找的数据,但是,我发现你指定位置的几个.INF文件没有包含“制造商”值,所以我添加了一些逻辑来说明重新没有价值。最后,我没有在我的测试工作站上的任何位于该路径的inf文件中看到任何DeviceID字段,所以我认为您所指的是ClassGUID。
Function Get-DriverInfo {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[String[]] $Source
)
$Drivers = Get-ChildItem -Path "$Source\*" -Recurse | Where {$_.Extension -eq ".inf"} | Select -ExpandProperty FullName
Foreach ($Driver in $Drivers)
{
Write-Output "Processing File: $Driver"
$GUID = (Get-Content -Path "$Driver" | Select-String "ClassGuid").Line.Split('=')[-1].Split(' ').Split(';')
$Version = (Get-Content -Path "$Driver" | Select-String "DriverVer").Line.Split('=')[-1].Split(' ').Split(';')
if ((Get-Content -Path "$Driver" | Select-String "MfgName") -eq $null)
{
$Manufacturer = "No Manufactuer Listed in INF"
}
ELSE
{
$Manufacturer = (Get-Content -Path "$Driver" | Select-String "MfgName").Line.Split('=')[-1].Split(' ').Split(';')
}
Write-Output "$Manufacturer, $Version, $GUID"
}
}
您将通过运行使用上述功能:
Get-DriverInfo -Source "C:\Windows\System32\DriverStore\FileRepository"
您可能需要调整输出格式,以您的喜好,但是这应该让你在正确的道路,以解决您的问题上。
编辑 思想我想补充的输出将是什么样子,第一部分显示了制造商和其他节目INF无制造商(路径被缩短了可读性):
PS C:\> Get-DriverInfo -Source "C:\Windows\System32\DriverStore\FileRepository"
Processing File: C:\Windows\System32\DriverStore\FileRepository\...\bcbtumsLD.inf
"Broadcom", 09/25/2013,6.5.1.4800, {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
Processing File: C:\Windows\System32\DriverStore\FileRepositor\...\bcmhidnossr.inf
No Manufactuer Listed in INF, 03/28/2013,1.0.0.101, {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
希望这有助于!
很酷,但不适合。 (我想如果不是制造商,请跳过结果关于GUID,我的意思是model。例如Manufacter =“HP”,Model =“HP Photosmart 2570”或“HP Color LaserJet 2820”(不要紧)DriverVer =“ 6.1.7600.16385“ –
听起来像是你要求的东西是不可能的,除了我上面输出中列出的版本和制造商之外,你将无法得到任何不同的结果,最后模型通常不在驱动程序中安装文件(inf),因为驱动程序可以应用到一系列广泛的硬件上,你可以使用notepad ++或类似的东西打开inf文件,看看它们包含的信息,不能得到那些不存在的信息 –
准确!需要* .inf中的所有模型。最后制作一个表格,列出制造商,所有可能的型号和驱动程序版本。 –