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?

October 19, 2022 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
7
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

Configuring Event Viewer Log Size on Windows

May 24, 2023

How to Detect Who Changed the File/Folder NTFS...

May 24, 2023

Enable Single Sign-On (SSO) Authentication on RDS Windows...

May 23, 2023

Allow Non-admin Users RDP Access to Windows Server

May 22, 2023

How to Create, Change, and Remove Local Users...

May 17, 2023

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

  • Configuring Event Viewer Log Size on Windows

    May 24, 2023
  • How to Detect Who Changed the File/Folder NTFS Permissions on Windows?

    May 24, 2023
  • Enable Single Sign-On (SSO) Authentication on RDS Windows Server

    May 23, 2023
  • Allow Non-admin Users RDP Access to Windows Server

    May 22, 2023
  • How to Create, Change, and Remove Local Users or Groups with PowerShell?

    May 17, 2023
  • Fix: BSOD Error 0x0000007B (INACCESSABLE_BOOT_DEVICE) on Windows

    May 16, 2023
  • View Success and Failed Local Logon Attempts on Windows

    May 2, 2023
  • Fix: “Something Went Wrong” Error When Installing Teams

    May 2, 2023
  • Querying Windows Event Logs with PowerShell

    May 2, 2023
  • Configure Windows LAPS (Local Administrator Passwords Solution) in AD

    April 25, 2023

Follow us

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Installing RSAT Administration Tools on Windows 10 and 11
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Delete Old User Profiles in Windows?
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • Adding Drivers into VMWare ESXi Installation Image
Footer Logo

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


Back To Top