Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

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

June 8, 2023

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.
15 comments
10
Facebook Twitter Google + Pinterest
PowerShellWindows 10Windows 11Windows Server 2019Windows Server 2022
previous post
Configuring RDP/RDS Sessions Limits (Timeouts) on Windows
next post
Configure Auto-Reply (Out of Office) Message in Exchange and Microsoft 365

Related Reading

How to Repair EFI/GPT Bootloader on Windows 10...

March 16, 2024

How to Restore Deleted EFI System Partition in...

March 11, 2024

How to Allow Multiple RDP Sessions on Windows...

March 15, 2024

How to Run Program without Admin Privileges and...

June 8, 2023

Wi-Fi (Internet) Disconnects After Sleep or Hibernation on...

March 15, 2024

How to Install Remote Server Administration Tools (RSAT)...

March 17, 2024

How to Repair Windows Boot Manager, BCD and...

March 11, 2024

Refresh AD Groups Membership without Reboot/Logoff

March 15, 2024

15 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
Derek December 18, 2024 - 8:33 pm

A couple things I would modify here.
1. After adding drivers and before you convert install.wim back to install.esd, delete the original install.esd, or you will have 2 install options listed because it merges the two install.esd files.
2. Before creating the ISO delete the install.wim out of the sources otherwise it’s additional files in your ISO taking up space that don’t need to be there.
3. The oscdimg command listed doesn’t work with Windows 11 23H2 and 24H2 in my testing for some reason, it corrupts the install.esd file. I had to use CDBurnerXP to create an ISO that didn’t corrupt the ISO (Free ISO Creator didn’t work either, that also corrupted the ISO).

Reply
admin December 21, 2024 - 6:52 am

Thank you for sharing this! I will definitely add it to the post.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • Fix: Remote Desktop Licensing Mode is not Configured
  • How to Delete Old User Profiles in Windows
  • Configuring Port Forwarding in Windows
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
Footer Logo

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


Back To Top