Imagine never needing to worry about drivers during Windows Operating System deployment ever again.
No need to manually download drivers. No need to maintain driver folders on your deployment shares. No need to update drivers whenever something breaks…
Every Windows deployment environment seems to manage OS drivers differently. Whether it’s dumping every driver into a single folder in your deployment share, one driver folder per OS, or one driver folder per model, these all require manual maintenance of your deployment share. What if there was a way to automatically, reproducibly, and consistently download OS drivers at deployment time…?
Scrape manufacturer websites using RegEx for direct driver download URLs. RegEx works well for this but…
With that out of the way, I’ll start by sharing the entire script, then describing it in more detail below. I’m always open to suggestions, so feel free to open a pull request or comment below!
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Downloads and installs Windows drivers directly from Manufacturer websites.
.DESCRIPTION
This script is meant to be invoked during Windows Operating System Deployment
to install drivers from common Hardware Manufacturers such as Lenovo, Dell,
HP, etc. This script *can* also be used to update drivers of live systems,
but may lead to system instability caused by replacing storage, network,
display, etc. drivers.
.PARAMETER Manufacturer
The Manufacturer of the device. Must be one of 'LENOVO', 'DELL', 'HP', 'MICROSOFT'.
.PARAMETER Model
The literal regex string that matches a URL on the Manufacturer's website
pointing to the exact download URL of the driver.
.PARAMETER SkipDownload
[OPTIONAL] Don't download drivers from the Manufacturer website. Just execute
drivers that were previously downloaded.
.PARAMETER SkipPnP
[OPTIONAL] Don't install drivers via pnp.
.PARAMETER SkipCleanup
[OPTIONAL] Don't cleanup temporary folders or registry keys.
# Example: <a ... href="https://download.microsoft.com/download/f/7/0/f70b3d0a-59b1-4842-9130-0c152bb738ba/SurfaceLaptop4_Win11_22000_22.093.37381.0.msi" ...>click here to download manually</strong></a>
$file_regex = '(http.*?\.msi)'
$match_index = 0
}
default { throw"Manufacturer [$Manufacturer] is not (yet) supported..." }
Refer to the code above for the most up-to-date information.
I wrote this script to simplify deploying drivers in my environment. What began as an idea to use RegEx to scrape driver URLs quickly turned into a fully automated solution (thanks Powershell!). This script is slightly modified for GitHub to include all the steps necessary to download, install, and deploy OS drivers.
Automating driver downloads from manufacturers is no discovery. As far as I can tell, manufacturers have been publishing discoverable web endpoints (of varying usefulness…) for driver downloads for over a decade now. Recently, I’ve seen these endpoints improve to the point that this script is now possible. What I haven’t seen is a single script that does everything from scraping the endpoint, to downloading, to installing, without the need to jump through intermediary cab files. What this solution provides is simplicity. No need to worry about OS drivers beyond specifying the manufacturer and model.
The scripted solution can be run directly from your system being deployed in WinPE or WinRE. The Manufacturer parameter tells the script which website to query for drivers. The Model parameter tells the script to query the manufacturer’s website for the exact string of your query and find the associated driver download link.
Once the download link for the driver pack is obtained, the script downloads the file to the local $env:TEMP directory and leverages pnpunattend.exe to install all drivers in that directory. Finally, the script cleans up files placed in $env:TEMP and exits.
This is where I acknowledge that downloading drivers from the manufacturer’s website during deployment may increase deployment times (vs. downloading from an internal endpoint). This is a worthwhile trade-off for the time saved from managing individual driver packs in deployment shares. While this script applies OS drivers before booting into the OS during deployment, I would also recommend running Windows Updates once booted into the OS for the first time.
This script also assumes that manufacturers test their drivers before deployment (not always the case), and that the “latest” OS version drivers will work on your systems. You’ll have to discuss if this added automation is a worthwhile trade-off with your team. Heck, feel free to fork this script entirely to add resiliency, or submit PRs to improve the script itself.
Hopefully, this script saves you some time that could be better used on automation, rather than fumbling with OS driver deployment 💻🔂⏩