Overview

One of the more tedious aspects of preparing new hardware for OS deployment with Configuration Manager is the driver import process. The process involves identifying the driver, downloading or extracting it to a central location, and then importing it. Rinse and repeat until all of the exclamation marks disappear in the Device Manager. This can make for a long morning and the temptation to grab a full driver cab and import the whole thing and be done with it is great. But then you are left with a bloated driver package where most of the drivers aren't even required. 

I can't help you avoid having to download a bunch of drivers but with the help of this script, we can identify precisely what your computer needs and only import those drivers. Thus creating a much smaller and manageable driver store. 

In order to do this, the script needs to:

  1. Identify all of the hardware Names and DeciveIDs in Win32_PNPEntity
  2. Toggle the ability to only search for unknown devices
  3. Extract a string from the DeviceID to be used as our regex espression
  4. Recursively search a given directory for INF files that contain our regex expression
  5. Return a device object with an array of INF file locations for each found device INF

Parameters

The script takes 3 parameters:

[parameter(Mandatory=$true,ValueFromPipeline=$True)]

[string]$SearchDir, #Directory to search


[parameter(ValueFromPipeline=$True)]

[string]$Computer = ".", #Computer to search


[parameter(ValueFromPipeline=$True)]

[switch]$UnknownOnly #Determines whether to return all devices or just unknown

Usage

Get all local driver INFs

C:\>Driver_INF_File_Search.ps1 -SearchDir C:\Dell 

 

Get all driver INFs for computer named TESTPC

C:\>Driver_INF_File_Search.ps1 -SearchDir C:\Dell -Computer TESTPC


 

Get unknown local driver INFs

C:\>Driver_INF_File_Search.ps1 -SearchDir C:\Dell