Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / How to Add/Remove Drivers to a Windows WIM/ISO Install Image

June 8, 2023 PowerShellWindows 10Windows 11Windows Server 2019Windows Server 2022

How to Add/Remove Drivers to a Windows WIM/ISO Install Image

You can simplify the deployment of the operating system on typical workstations (servers) if you add all the necessary drivers to the Drive Store of your Windows install image. In this case, after installing Windows, you don’t have to manually download and install specific drivers (including AHCI/RAID/NVMe) on each computer.

In this article, we’ll show you how to integrate device drivers directly into a Windows 10 offline install image (it can be an ISO/WIM file or a VHD/VHDX file with an OS template). The instruction is applicable for all supported versions of Windows 11, 10, 8.1 and for Windows Server 2022, 2019, 2016, and 2012 R2.

Contents:
  • Inject Drivers into a Windows Install Image using PowerShell
  • Add Drivers to an Offline Windows Server Image Using DISM
  • Remove Driver Packages from a Windows Image

In current Windows editions, you can add drivers to the installation ISO image in two ways:

  • using the DISM tool;
  • with PowerShell CLI.
Note. In Windows Server 2008 R2 and Windows 7, it was possible to add a driver to the Windows installation image using the imagex command line tool (included in the WAIK), but it is not supported in Windows Server 2012 and later.

Inject Drivers into a Windows Install Image using PowerShell

Download and copy all the necessary device drivers in one directory (you need to create a separate folder for each driver). Please note that many vendors (including Dell, HP, Lenovo, etc.) supply their drivers in the form of self-extracting exe or zip archive files. Such archives must be unpacked to a local disk so that inf, cat, and sys files are located in the directory with the driver.

Before you start, create the following directory structure on your local drive:

  • The Drivers folder – it contains unpacked driver files for your computer (which are supposed to be integrated into the Windows 10 install media);
    You can manually download and extract the necessary driver files or export all third-party drivers from a reference Windows 10 computer that has all the necessary drivers already installed using the Export-WindowsDriver cmdlet.
  • The ISO folder – this directory contains the extracted Windows 10 ISO image. You only need the install.wim file from the Sources directory;
  • The Mount folder – an empty directory into which the Windows install WIM image will be mounted.how to add drivers into a Windows 10 image

List all Windows editions contained in the install.wim file using the Get-WindowsImage PowerShell cmdlet. This will allow you to get an index of the Windows edition in which you plan to integrate additional drivers.

Get-WindowsImage -ImagePath C:\WinWork\ISO\install.wim

Get-WindowsImage install.wim

In our example, the WIM file contains only one Windows 10 Pro edition with the index 1 (ImageIndex: 1).

If your Windows 10 ISO image contains only the file …\sources\install.esd, you can convert the ESD file to WIM format using the DISM tool:

DISM /export-image /SourceImageFile:"C:\WinWork\ISO\install.esd" /SourceIndex:4 /DestinationImageFile:C:\WinWork\ISO\install.wim /Compress:max /CheckIntegrity  dism convert install.esd to install.wim  

Next, you need to mount the image of the selected Windows edition to the Mount directory. As an argument to the Index parameter, specify the index of the Windows image you want to mount:

Mount-WindowsImage -Path C:\WinWork\Mount\ -ImagePath C:\WinWork\ISO\install.wim -Index 1

Mount-WindowsImage install.wim

After the image is mounted, you can add drivers to it from the Drivers directory using the command:

Add-WindowsDriver -Path C:\WinWork\Mount\ -Driver C:\WinWork\Drivers -Recurse

The Add-WindowsDriver cmdlet will recursively scan (the -Recurse parameter) the specified folder for all *.inf files with the driver description. According to the description in the inf file, the cmdlet will add the dependent INF, DLL, CAT, PNF, etc. files to the offline Driver Store of your Windows image.

Add-WindowsDriver powershell cmdlet to inject drivers to the offline install.wim image

Using the -ForceUnsigned key, you can add unsigned drivers to the driver store. Otherwise, you will have to disable the digital signature enforcement or sign the device driver with a self-signed certificate.  

After the driver’s files have been copied, commit your changes and unmount the WIM image.

Dismount-WindowsImage -Path C:\WinWork\Mount\ –Save

Dismount-WindowsImage - save changes

In this example, we have added drivers to the install.wim image file. This is the Windows image that will be deployed to the local drive of the computer. If you need to add drivers to a Windows boot image (WinPE environment used to boot the computer and run the Windows Setup), you need to add drivers to the Boot.wim file. This is usually needed if Windows Setup doesn’t detect local hard drives, video, or network adapters. Usually, it is enough to add only drivers for disk controllers or network adapters to the boot.wim image.

In the same way, you can add drivers to the Windows Recovery Environment (winre.wim) image.

You can convert your install.wim file containing the Windows installation image with integrated drivers into the install.esd format using the DISM compress option:

DISM /Export-Image /SourceImageFile:C:\WinWork\ISO\install.wim /SourceIndex:1 /DestinationImageFile:C:\WinWork\ISO\install.esd /Compress:recovery

It remains to create an ISO file using Dism++ or the oscdimg tool and write it to a disk or USB flash drive:

oscdimg -n -m -bc:\WinWork\ISO\boot\etfsboot.com C:\WinWork\ISO C:\new_win10pro_image.iso

This command will create an ISO image for installation on a computer with BIOS firmware or in UEFI Legacy mode (CSM/Compatible Support Mode).

oscdimg: build windows install iso image

In order to generate a universal ISO image with both UEFI and BIOS support, use the command:

oscdimg.exe -h -m -o -u2 -udfver102 -bootdata:2#p0,e,bc:\winwork\iso\boot\etfsboot.com#pEF,e,bc:\winwork\iso\efi\microsoft\boot\efisys.bin -lWin10 c:\iso c:\new10image.iso

To burn an ISO image file to a USB flash drive, the easiest way is to use the Rufus utility.

The oscdimg tool is part of the Windows ADK (Assessment and Development Kit). Download and install the ADK for your version of Windows, and then choose to install Deployment Tools.

Windows 8 ADK Deployment Tools

Now you can use your custom image to deploy Windows on computers from a local boot device (USB disk or flash drive) or install Windows over the network (using PXE boot).

There is no Add-WindowsDriver cmdlet in Windows 7 and Windows Server 2008 R2. It appeared only in Windows 8/ Windows Server 2012 and newer. Therefore, use DISM to integrate drivers into an image of Win7/2008 R2 (see the example below or in the article Add USB 3.0/NVME Drivers to Windows Image).

Add Drivers to an Offline Windows Server Image Using DISM

Now we will show an example of adding drivers into a Windows Server 2022 install image.

Use the same directory structure: Drivers (drivers and *.inf files are stored here), ISO (unpacked image of Windows Server 202), Mount (image mount directory). All image modification operations are performed from a Windows 10 desktop computer.

List the editions in a WIM file:

Dism /Get-ImageInfo /imagefile:"C:\iso\sources\install.wim"

dism: get wim image info

Learn more about using DISM to find the Windows version, build, and edition from an ISO or WIM image file.

In this example, I going to inject drivers to a Windows Server 2022 Standard (Desktop Experience) image with Index:2.

Mount the install.wim installation image:

dism /Mount-Wim /WimFile:c:\iso\sources\install.wim /Index:2 /MountDir:c:\mount

Now search for drivers (recursively) and add new drivers into the driver store of the Windows Server 2022 image:

dism /image:c:\mount /Add-Driver "/driver:c:\drivers\" /recurse

adding drivers to windows image using dism

You will see the following message for each successfully added driver:

driver.inf: The driver package was successfully installed.

Save the changes to the WIM image:

dism /unmount-wim /mountdir:d:\mount /commit

You may also have to add drivers for network adapters and disk controllers into the boot image file boot.wim.  

If you want to add drivers to all Windows Server editions contained in the installation image, you must perform these steps for all indexes in the install.wim file.

In addition to driver integration, it can also inject security updates to the Windows install image. This will increase the security of your OS immediately after the installation. It remains to write your custom installation image to the boot disk or USB flash drive or convert it to the ISO image file.

Remove Driver Packages from a Windows Image

In some cases, you may need to remove drivers from the Windows WIM installation image (when removing old/incorrect drivers, or reducing the size of the ISO image).

To do this, mount the offline WIM image to a local folder:

Mount-WindowsImage -Path C:\Mount\ -ImagePath C:\iso\sources\install.wim -Index 2

List third-party drivers in the offline Windows image:

Get-WindowsDriver -Path "c:\Mount"

get-windowsdrivers: list drivers in iso image or wim file

To remove a specific driver, you need to specify its inf file name (oem<number>.inf):

Remove-WindowsDriver -Path "c:\offline" -Driver "OEM0.inf"

remove-windowsdriver from windows image with powershell

You can remove specific vendor drivers from an image. In this example, we’ll remove all Intel drivers:

$drivers = get-windowsdriver -path C:\mount
$drivers | where-object {$_."ProviderName" -eq 'Intel' }  | Remove-WindowsDriver -Path C:\Mount

Commit changes to the WIM image file:

Dismount-WindowsImage -Path C:\Mount -save

Please note that over time, the driver store folder (%WINDIR%\System32\DriverStore\FileRepository) can grow significantly, so you need to remove old drivers from the driver store periodically.

13 comments
8
Facebook Twitter Google + Pinterest
previous post
Configuring RDP/RDS Sessions Limits (Timeouts) on Windows
next post
Using VMware Converter for P2V Migration (Physical to Virtual)

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

13 comments

Peter May 11, 2019 - 1:48 pm

Thanks for posting found it very helpful.

Reply
ayyu3m November 8, 2019 - 8:29 am

There is a missing double co colon right after SourceImageFile when trying to convert back to install.esd

DISM /Export-Image /SourceImageFile:C:\WinWork\ISO\install.wim /SourceIndex:1 /DestinationImageFile:C:\WinWork\ISO\install.esd /Compress:recovery

Reply
j00d July 20, 2019 - 1:36 pm

for the

oscdimg -n -m -bc:\ISO\boot\etfsboot.com C:\ISO C:\new_win10pro_image.iso

you got all the paths wrong, it should be c:\winwork\iso you are missing that directory in your sample

Reply
Kattz July 22, 2019 - 6:24 am

I have 3 oddball Windows 10 tablets. I have Windows System Image backups for them, but Windows can’t see them. I just really need the driver’s from the images. Would I be able to extract them from the images using any of the above methods? I’m frustrated and confused at this point. I’ve tried many different things and nothing has worked. I would appreciate any advice. Thanks.

Reply
admin July 22, 2019 - 1:26 pm

Mount your vhdx file from your Windows System State Backup to a separate drive letter (for instance, e:) and try to export the installed device drivers from your offline image as follow:

Export-WindowsDriver -Path e:\windows -Destination c:\DriverBackup

Reply
Scott May 12, 2020 - 1:33 am

DISM /Export-Image /SourceImageFile C:\WinWork\ISO\install.wim /SourceIndex:1 /DestinationImageFile:C:\WinWork\ISO\install.esd /Compress:recovery

“C:\WinWork\ISO\install.wim”

Is not a known command-line option.

Reply
admin May 15, 2020 - 6:20 am

The colon is missing right after SourceImageFile. I fixed the command in the post. Thanks!
You should use the command:
DISM /Export-Image /SourceImageFile:C:\WinWork\ISO\install.wim /SourceIndex:1 /DestinationImageFile:C:\WinWork\ISO\install.esd /Compress:recovery

Reply
Juan Pedro October 14, 2020 - 5:44 am

Excellent tutorial. Thank you.
Just as mentioned by J00D, the path for the creation of the ISO need to be commented.

.\oscdimg -n -d -m -bC:\WinWork\Original\iso\boot\etfsboot.com C:\WinWork\Original\iso\ C:\WinWork\new_win10pro_image.iso

Where “C:\WinWork\Original\iso\” is the location of the full original content of the ISO. The one expanded at the very beginning.

Also, “oscdimg” can be downloaded from https://answers.microsoft.com/en-us/windows/forum/windows_7-windows_install/where-is-oscdimgexe/b6ccd22e-b478-4222-b370-d5aaf021f575

And you could add to “oscdimg” the parameter “-d” to keep the case definition (lower or upper).

Reply
texhunt January 2, 2022 - 3:28 am

This is a fantastic article!

Reply
Baboo85 January 21, 2022 - 9:52 am

This is a fantastic guide, but when I tried to install Windows it says that install.esd is corrupted or something and can’t go further.
During the conversion I had no errors.

Reply
Baboo85 February 3, 2022 - 2:49 pm

NVM I used the WIM file and it went well.

Reply
ryle_85 May 5, 2022 - 2:44 pm

Hi great article and very helpful – I have followed all, however, after the following:
oscdimg -n -m -bc:\ISO\boot\etfsboot.com C:\ISO C:\new_win10pro_image.iso
when I use Rufus to create a bootable USB, the final iso created is not accepted as a bootable media – any ideas?

Reply
ryle_85 June 28, 2022 - 2:50 pm

any help or suggestions with once completing your helpful guide, burning the iso to USB? When using rufus I get the following error message:
Unsupported image
This image is either non-bootable, or It uses a boot or
compression method that is not supported by Rufus…

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top