Drivers

PowerShell is King – Export drivers from Windows

During the OSD Deployment class this week we talked about drivers, one question was “is it possible to cheat?” and the answer is “Yes”

If you have a Windows 8.1/Windows Server 2012 R2 (or later) you can take the new PC, boot it and extract the drivers using PowerShell and then import them in MDT, ConfigMgr to deploy them, or use PNPUtil.exe to inject them.

How to export drivers

Export-WindowsDriver -Destination "C:\Drivers\$((Get-WmiObject -Class win32_computersystem).Model)" -Online

This command will create the folder c:\Drivers\”ModelName” and export all drivers from the running OS into that folder, like this:

image

Should I remove anything before import?

Yes, usually you don’t want the printer drivers, so you can remove the folders that starts with prn…. Those are printer drivers, like OneNote and similar…

What about import?

If you need to import them you can either use forfiles.exe plus pnputil.exe

https://deploymentbunny.com/2011/05/07/adding-drivers-using-pnputil-and-forfiles/

or you can of course use PowerShell…

$infs = Get-ChildItem -Path "C:\Drivers\$((Get-WmiObject -Class win32_computersystem).Model)" -Filter "*.inf" -Recurse -File
foreach($inf in $infs){
    $inf.FullName
    pnputil.exe -i -a ""$inf.FullName""
}

 

image

/mike

Categories: Drivers, PowerShell

Tagged as: ,

8 replies »

  1. PS C:\Users\Administrator> Export-WindowsDriver -Destination “C:\drivers1\$((Get-WmiObject -Class win64_computersys
    Model)” -Online
    无法将“Export-WindowsDriver”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请
    路径正确,然后重试。
    所在位置 行:1 字符: 21
    + Export-WindowsDriver <<<

    ???

    • Well, the function does export only non-built-in Microsoft drivers, so it does the same thing actually, you can import the drivers exported this way in the same way into ConfigMgr/MDT

Leave a comment

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