How to create a custom Windows 11 image with Hyper-V
When administrators can deploy Windows systems in many ways, creating a custom VM with Hyper-V enables them to efficiently deploy a copy of one desktop to a whole user base.
There are many ways to acquire or install a Windows desktop, including purchasing preinstalled systems, installing a base image manually and running Windows virtually, but enterprise organizations can use Hyper-V for this purpose.
IT administrators can use reference images in Hyper-V for which they build carefully customized Windows images. These include applications, preferences and settings -- all set up and ready for targeted users to put to work as soon as they log in to their PCs.
Desktop administrators should learn how these Hyper-V images work and how to make the most of them so they can efficiently deploy and manage Windows desktops.
An overview of how to create a custom Windows 11 image with Hyper-V
As an IT professional who wants to create a custom Windows 11 image for deployment, you should generally start by setting up what's called a technician computer using Windows Assessment and Deployment Kit and Windows Preinstallation Environment.
Then, install Windows 11 on a reference PC that matches or closely approximates a configuration for target users, and apply customizations, including device drivers, applications and settings. After that, use the Microsoft Windows Deployment Image Servicing and Management (DISM) tool to capture that customized image. And, finally, it's a good idea to save that custom image to a network share or bootable media so you can deploy it to target PCs as needed.
The customization process usually commences with preparing a custom Windows environment using the Microsoft System Preparation (Sysprep) tool. Next, capture that customized image using DISM to create an installable ISO image.
It's best practice to create a checkpoint just prior to running Sysprep and another while the VM is shut down immediately after Sysprep has finished. These can be useful if you discover changes that you need to make or if an error pops up.
Create a customized Windows 11 OS image, step by step
Creating an image requires you to boot from the same Windows installation media used to create the VM. You should not boot that VM from the virtual hard disk (VHD) before this snapshot is created.
This example uses a host desktop running Windows 11 Pro 24H2, and the Hyper-V machine runs the same OS, Windows 11 Pro 24H2.
To boot a Hyper-V VM from the Windows installation media, perform the following steps:
In Hyper-V Manager, select the Technician System, and then select Settings… (Figure 1).
Figure 1. After you select Technician System, the settings to manage the new VM
On the Settings screen, select Firmware, and then select the DVD Drive for your installation media. Move this to the uppermost position in the boot order list by using the Move Up or Move Down buttons (Figure 2).
Figure 2. The firmware selected from the list of hardware options within the Hyper-V interface
Start the VM. You are asked to press any key. Be prepared: You only have a short time to act. If you miss this window of opportunity or something goes wrong and the VM boots from the VHD rather than the installation media, you need to restore your last checkpoint and try again.
When Windows Setup pauses at the first static screen -- the regional selections screen -- press Shift + F10 to open a command prompt.
Type diskpart, and hit Enter to start the Windows disk partitioning utility. Enter the command list vol to display available volumes. Note that drive letter assignments here may be different from a normal Windows desktop. If your Windows volume shows no drive letter, assign one so it can be referenced in the following. To assign a drive letter, issue these commands:
select volume 3 assign letter=D
Note that, in the preceding commands, volume 3 is the Windows system boot drive. Make certain to use whatever volume number corresponds to the Windows volume on your PC. You can assign any available drive letter -- A to Z. This letter is only temporary to allow access while booted from installation media.
Repeat this process for the image partition.
While this example uses a volume different from the Windows volume to save the image, it is perfectly acceptable to use the same volume where Windows resides as both the scratch disk and the destination for the snapshot. The two are differentiated solely for clarity and easy discrimination.
Enter the command exit to leave diskpart. Enter the following DISM command to create an image of your custom Windows environment. You can cut and paste this text for use:
Edit the following to meet your needs if necessary:
/imagefile:E:\image\install.wim. This is the path where install.wim is saved.
/capturedir:D:\. This is the Windows drive letter while booted from installation media.
/scratchdir:E:\Scratch. Temporary working folder created on the image drive.
/name:"AnyName". Any name that you like (Figure 3).
/description:"AnyName". Any description that you like (Figure 3).
Figure 3. The Windows 11 Setup pop-up dialog showing the differently named OSes and their descriptions
Best practice is to include both a NAME and DESCRIPTION in the DISM command, even if you use the same text for both elements. This is because some configurations don't work properly if either of these entries is missing.
Press Enter to run the command. This can take quite some time, depending on factors such as your hardware and available system resources. Be patient, as progress may appear to stall, especially at the start, where no progress could be reported for 15 minutes or longer.
When DISM finishes, reboot the VM, and allow it to boot from the VHD normally. Your image has now been created. Next, you simply need to save that image to some location outside of the VM in which it currently resides.
Once booted to the desktop, save the install.wim file created in E:\Image to the host PC. Next, shut down the VM. You may need to configure networking within the VM to do this. Alternatively, you may also attach storage to the VM. Then, you can save the install.wim file to that attached drive.
On the host PC, mount the original Windows install media ISO used to create the Technician System. Create a folder named ISO_Files on your host system, and copy all content from the mounted ISO into that folder. In the ISO_Files\Sources folder, replace the existing install.wim file with the customized install.wim file you saved in the preceding step. Also, copy the already created autounattend.xml file to the root of the ISO_Files folder.
Figure 4 shows ISO_Files folder contents when you're done.
Figure 4. The sources folder that contains the custom image file with the answer file below
Open an elevated Deployment and Imaging Tools Environment from Start > All as shown in Figure 5.
Figure 5. The process of opening an elevated session of Deployment and Imaging Tools Environment
Change your working folder to the root of the C: drive by using the CD\ command.
Enter the following command to create your ISO image:
In the preceding command, d:\iso_files refers to the location of the ISO_Files folder that you created earlier. If your location is elsewhere, be certain to change all three references. In addition, d:\Win11PRO.iso is the location and file name of the final ISO image you create. You can use any path and file name you might like here or leave it as is.
Booting from this media wipes the contents of the drive to which Windows is installed without warning. So, you must be careful and well informed to make proper use of that USB stick or other removable media.
This process doesn't take long, despite the number of steps involved. It typically takes only a minute or two to complete -- possibly less if you're using a speedy solid-state drive. When you're done, you may use this ISO to totally automate installations into any VM or copy it to a double-layer DVD, Blu-ray or USB flash drive so you can install it on a physical PC.
Label your media to note that it contains an answer file. Booting from this media wipes the contents of the drive to which Windows is installed without warning. So, you must be careful and well informed to make proper use of that USB stick or other removable media. At a minimum, you should be ready to recover from errors or boot failures, with access to recovery media and boot repair tools.
You now have a unique custom Windows image install media with preset user accounts and preinstalled software. You can use this media to perform automated Windows installations. Simply boot any PC from this custom installer media, follow the steps and you have a fully customized Windows instance ready to use.
On new or unfamiliar hardware, it is a good idea to rename your autounattend.xml file on your installation media. Next, boot from that media as a test. This allows you to run diskpart and determine the disk number that your installation media assigns to the disk upon which Windows is installed.
Then, you can modify your autounattend.xml file to reflect the actual disk ID and avoid accidentally wiping the wrong one. Once this is taken care of, rename the file back to autounattend.xml. This is important because referencing an incorrect drive number in the answer file may erase the wrong disk on your target system.
Be careful as you work through your images because even minor errors can result in an unusable image and a nonfunctional PC. Testing, verification and more testing are key to ensuring deployments work correctly, whether on a one-off or a large-scale basis.
Thanks to longtime Eleven Forum VIP member Hannes Sehestedt, whose technical input and review of these materials helped me establish and confirm the facts presented in this story.
Ed Tittel is a 30-plus-year IT veteran who has worked as a developer, networking consultant, technical trainer and writer.