First off, bear with me here during the intro. I know introductions usually are boring, but I do have a few words to share with you first.
The following is by no means any substitution for any other Modern Driver Management solution out there. This is purely me exploring, learning and sharing that experience with anyone who’s interested. When I find something useful, I usually try to do my own thing for various reasons, but mainly to learn and also for being less dependent on others work and future maintenance plans.
Now, this post is primarily about a Powershell script and how that Powershell script is designed to run on a given device and export the device drivers into your ConfigMgr source file library or locally. In the process, the script is able to create a regular package in ConfigMgr containing those drivers. The post is also about how to use the regular packages for applying drivers, but the script is what took the most of my time 🙂
The idea here is, that you fire up a given device with a given version of Windows (preferably Windows 10) and install ALL the drivers (preferably the latest drivers) and verify that everything works in that combination of Windows, drivers and hardware model.
Note: Most vendors provide a tool which checks online for latest drivers and gives you option to install those. This is pretty handy when building new drivers for a given computer model.
Now knowing that everything works, this is the drivers you want to apply to future deployments of this computer model, so you run the script and everything is automatically exported and a package in ConfigMgr is created.
In lack of a better name, this is what I call ‘Almost Modern Driver Management‘. 😀
PS. If you’re looking for a truly nifty and ‘modern’ approach, I suggest you head over to SCConfigMgr.com and take a peek at their solutions for both BIOS and drivers.
I recently did this to my ConfigMgr environment. It felt really good. Not because the regular way of doing drivers doesn’t work, it just quite easily becomes an administrative mess.
Instead I’m now doing this, keeping the drivers in regular packages. The packages shown here are the ones created with the Powershell script (Again, inspiration and help from @modaly_it)
And the content of the packages created will look similar to below (Note: It’s on my to-do to rename the native provided folders into a more friendly name. For now this will do just fine)
Using The Packages
I’m using the regular packages in a separate Task Sequence. Each package are conditionally downloaded with the Download Package Content step, and stored into the custom path: %_SMSTSMDataPath%\Drivers
And the drivers are applied ‘manually’ through DISM with a Run Command Line step:
DISM.exe /Image:%OSDTargetSystemDrive%\ /Add-Driver /Driver:%_SMSTSMDataPath%\Drivers /Recurse /logpath:%_SMSTSLogPath%\dism.log
The ‘Apply Drivers‘ step is only run if drivers actually are downloaded. As of such, add a condition to the step similar to below
And on the ‘Apply Drivers Using DISM‘ step, add success code ’50’ to the list. (DISM returns 50 when applying a driver)
And finally, the nested Task Sequence is used with the relevant main Task Sequences deploying the relevant version of Windows 10.
If you have several task sequences deploying the same OS version, this is preferred as you only have to modify the nested task sequence in order to affect everything.
The Powershell Script
There are 3 places in the script where you will have to make edits. Those are all marked with the comment ### EDIT HERE ###
Those places are:
- # SCCM specific variables
- # Directories where drivers are exported to
- # Get all Plug and Play devices on the computer
The script log all actions to ProgramData\Export-InstalledDrivers\Export-InstalledDrivers.log
If the script is run with the -ImportSCCM parameter, the user that runs the script is required to have permissions to create packages in the specified Configuration Manager environment.
The script also requires access to the Configuration Manager Powershell module in the default path: $ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1 which is installed with the console.
The script does following in headlines:
- Gets all Plug and Play devices from WMI
- Gets all Plug and Play drivers in WMI that matches the devices found
- Finds the matching driver in the driver store file repository: C:\Windows\System32\DriverStore\FileRepository
- Adds the full path to the driver into an array
- Copies all the drivers found out to the SCCM source file library (if run with -ImportSCCM) or down locally to C:\Temp\Drivers (if not run with -ImportSCCM)
- Create folder in SCCM if it doesn’t exist
- Create package in SCCM with the drivers
- Move the package in SCCM into the folder
The script has been tested on following Lenovo models:
- X1 Yoga 2nd
- X1 Yoga 3rd