Windows Reference Images for Rapid Virtual Machine Deployment

This article was last updated 2018-12-07.

Hello! When I was learning system and network administration, building test environments and virtual labs was a vital skill. When working with Windows administration having solid, up-to-date reference images sped up testing by enabling us to tear down and reset environments in minutes.

Creating reference images for virtual environments allow you to skip installing a fresh operating system every time you need a new machine. Windows reference images need to be set up properly or they will cause issues if multiple copies of the same reference image are connected to the same active directory domain.

So, let's learn how to set up proper reference images for Windows 10 Enterprise and Microsoft Server 2016 in Client Hyper-V. At the end of this guide, we will have:

  • Official ISO files for Windows 10 Enterprise and Microsoft Server 2016
  • Virtual hard disk images of fresh installs of Windows 10 Enterprise and Microsoft Server 2016 that can be repeatedly deployed for testing

Gathering Materials

The first thing that you need is to have the installation files for Windows 10 Enterprise and Windows Server 2016. Windows 10 Enterprise and Windows 10 Enterprise LTSC are available for free here, and multiple versions of Windows Server 2016 are available here for free as well.

Note: The downloads from the Microsoft Evaluation Center ask you to fill out information on your company, and provide contact details. However, none of this information is validated or used, so enter dummy data.

The version of Windows 10 Enterprise that you choose will depend on the environment you want to emulate. You will want to select the ISO for Windows Server 2016, because you will be making your reference image yourself. Once you have the images, you can install Client Hyper-V and get working.

Installing Client Hyper-V

The official requirements for installing Client Hyper-V on Windows 10 are located on Microsoft Docs here.

  1. Open the Start Menu and type Turn Windows Features on or off.
  2. Select Turn Windows Features on or off from the list.
  3. In the list, mark the checkbox for Hyper-V and press okay.
  4. You will be prompted to restart to complete the installation. Do so.
The Windows Features dialogue box, showing Hyper-V checked.

Installing Client Hyper-V using PowerShell

Open PowerShell as Administrator and enter:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Setting up your reference VM in Hyper-V

  1. Open Hyper-V Manager.
  2. On the right side, under Actions, select New > Virtual Machine. The New Virtual Machine Wizard will open.
  3. On the Specify Name and Location page, name your virtual machine. Click Next.
  4. On the Specify Generation page, select Generation 1 or 2. Selecting Generation 2 will change some of the menus later on when working with this virtual machine, but otherwise has no impact on our function. Click Next.
  5. On the Assign Memory page, give your virtual machine a decent amount of memory. I give my virtual machines 2-4GB and leave Dynamic Memory enabled. Dynamic Memory will let your Windows host reclaim memory not in use by your virtual machines. Click Next.
  6. On the Configure Networking page, select Default Switch from the drop-down menu. Click next.
  7. On the Connect Virtual Hard Disk page, select Create a virtual hard disk, and name the disk so it is easily identifiable later. Examples, win10ent-reference.vhdx and server2016-reference.vhdx.
  8. On the Installation Options page, select Install an operating system from a bootable CD/DVD-ROM and select one of the ISO files you downloaded earlier. Click Finish.

Quick script for creating a virtual machine for a fresh installation

$VMName = ClientGold
$ISOPath = "C:\Hyper-V\ISOs\1534.RS3.Win10Ent.x64.iso

New-VM -Name $VMName -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath "$VMName.vhdx" -NewVHDSize 127GB -SwitchName (Get-VMSwitch).Name
Add-VMDvdDrive -VMName $VMName -Path $ISOPath
Set-VMFirmware $VMName -FirstBootDevice (Get-VMDvdDrive $VMName)

Creating the reference images

To create the reference images, we will simply go through the installation process normally once you start up the virtual machine.

In Windows 10 Enterprise, you will be asked to login with a Microsoft account. Below and to the left there is a button that says Domain Join. Press that button to create a local account. We will be deleting this account before we finish up.

Once you have installed Windows 10 Enterprise or Windows Server 2016, open the  Settings app (Win + i) and navigate to Update & Security. Click Check for updates and let everything download and install. When it's finished, you will have to reboot, so do that. If it does not prompt you to reboot, do it manually.

After the reboot, and you are logged in fully, open File Explorer (Win + e) and navigate to C:\Windows\System32\Sysprep. Run sysprep.exe, and the Sysprep dialogue will appear.

Optionally, in Windows 10 Enterprise we can remove the account created on the VM. Select Enter Audit Mode, optionally select Generalize, Reboot and click okay.

Sysprep tool, entering audit mode and rebooting.

When the device reboots and enters audit mode, open Windows Search (Win) and type Add, edit, or remove other users. The Settings app will open to the users page. Under Other Users, you should see the local administrator account that you made when you initially installed. Remove it.

Once that's done, open the Sysprep tool, select Enter Out of Box Experience (OOBE), Generalize, and Shutdown, and click OK.

If you don't care about leaving behind a user from the previous install, once Windows 10 Enterprise is finished updating you can just run Sysprep with Enter Out Of Box Experience (OOBE), Generalize, and Shutdown selected, and move on.

Windows Server 2016

Windows Server 2016 does not create a new user when you install it. Instead it just assigns the local Administrator account a password. This will be removed when it Sysprep is run. After you finish updating Windows Server run Sysprep with Enter Out Of Box Experience (OOBE), Generalize, and Shutdown selected, and click OK.

Last Steps

The final step is moving our reference disks to a permanent home. Before we can move the files, we need to remove any checkpoints that Hyper-V has made. Open the Hyper-V Manager window, select your reference machine, right-click the top-level Automated Checkpoint, and select Delete Checkpoint.

Deleting the checkpoint rolls the virtual machine's current state into it's previous state, creating a single hard drive file. Once it is all rolled up, we can move it to a dedicated folder for reference images so can find them later. On my machine, I use C:\HyperV\reference to store my reference images.

Using the reference images in Hyper-V

To use the reference images, we need to create a differencing disk. This is a VHDX file that only stores the differences between the current state and the state of the parent image. After the first time we boot it up, it will take up about 4-5GB, but that is significantly smaller than multiple different installations.

Note: Once you create a differencing disk and select the target reference disk, you cannot move the reference disk without breaking the child images.

  1. In the Hyper-V Manager window, click New > Hard Disk.... The New Virtual Hard Disk Wizard will open.
  2. In the wizard, select Differencing Disk, then click Next.
  3. Choose the name of your virtual hard disk, and where it is stored. Click Next.
  4. On the Configure Disk page, click Browse and select the reference image you want this disk to be based on. Then click Next.

Now that we have the differencing disk, all that's left is to create a new virtual machine to attach it to. When you are creating your virtual machine, at the hard drive step, select your hard drive. After you create the virtual machine, you will have to go into its settings and edit the boot order to ensure it boots from the drive first.

It may take a little while the first time one of your child disks start up. This is due to the Generalize that we preformed earlier that removed machine-specific information that now needs to be regenerated for this new machine.

Once a child VM has started, the bottom corner of the desktop shows the current status of the VM's license. The evaluation license should be between 90 and 180 days. Because we ran Sysprep.exe, every time we create a new child disk off our reference disk it will have a fresh license of 90 or 180 days.

The evaluation license is valid for 90 days.

What next?

I don't know what you needed these for. Create a lab environment. Deploy active directory. Configure group policy. Create a PKI environment. Infect them with malware (you'll need a more robust lab for this). Or do whatever else you would want short-term Windows virtual machines for.

Support the Author

Devon Taylor (They/Them) is a Canadian network architect, security consultant, and blogger. They have experience developing secure network and active directory implementations in low-budget and low-personnel environments. Their blog offers a unique and detailed perspective on security and game design, and they tweet about technology, security, games, and social issues. You can support their work via Patreon (USD), or directly via ko-fi.