How to Export Third-Party Drivers with PowerShell

I’ve recently accepted a new role and joined a new company this week. During the first day, I followed my usual practice of using Chocolatey to install most of the developer’s tools I will use, installed WSL2, and created a full backup of the laptop.

Working in operations for most of my career and the improvements of package managers on Windows OS and WSL2, I can tweak the configuration with just the things that make me as productive as on a Linux OS.

Exporting third-party drivers

As a useful step, I’ve also decided to export a copy of all drivers on another volume so if needed I can reinstall the previous version without visiting the vendor’s website or restoring the OS from the backup.

#Requires -RunAsAdministrator

# Paolo Frigo, https://scriptinglibrary.com

# More details on:
# https://docs.microsoft.com/en-us/powershell/module/dism/export-windowsdriver?view=windowsserver2019-ps#examples

$DestinationFolder="D:\Drivers\"

if (Test-Path -Path $DestinationFolder){
    Export-WindowsDriver -Online -Destination $DestinationFolder
}
else {
    Write-Error "Invalid Path: $DestinationFolder"
}

Tip

Similar to automated backups, also this step could be automated or scheduled every month or quarter.

Useful Links

There are a few scenarios where this can be useful, but I recommend starting from the official documentation for also other cmd-lets that are related:

Wrap-Up

In my personal opinion when it comes to provisioning the image of the system should contain everything essential. Everything else I like to add is on-demand with package managers (or configuration managers).  Once the provisioning is completed, to be more flexible and mitigate risks I will also have frequent (automated) backups and export third-party drivers or configurations. Know that every workstation that I used share the same resources or state thanks to cloud services.
As usual, you can find this script on my Github repository.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.