How to Make Windows Templates for Virtual Machines
This guide will help you make Windows templates for virtual machines. We’ll use a tool called Sysprep and learn how to use it. In the end, we’ll learn how to get the templates ready for the next step, which is making differencing hard drives.
What You Need
Before we start, make sure you have these::
Creating Virtual Machine
After you’ve downloaded the ISO file, we need to make a virtual machine. For this example, we’ll make a template for Windows Server 2022.
Open Hyper-V Manager and create a new VM.
Follow the steps in the wizard. Choose a recognizable name for the VM, such as “Template-WinServer22”.
Choose Generation 2 for the virtual machine.
Assign memory and use dynamic RAM to save on memory space.
For now, choose the Default Network Switch.
Create a new Hard Disk and change the location to the templates folder.
Finally, attach the ISO that you downloaded earlier.
Before you start the VM, turn on Secure Boot and TPM. Then, start the VM and boot from the DVD Drive.
Getting the Templates Ready
We’re using our everyday machine to make this lab, so we don’t have powerful hardware like physical servers do. So, the biggest challenge is how to save some space. My idea is to make a parent hard disk that will be used as the operating system.
All our virtual machines will then use the parent operating system. This way, we won’t need to install the operating system for every virtual machine, we will just use the parent operating system (Windows Template). Then we will create a differencing disk, that will be attached to the virtual machine and will only contain differences.
In this case, the parent operating system will be a Windows server template.
So all our Windows Server virtual machines will use the Windows Server 2022 Template and all Windows virtual machines will use Windows 11 Templates.
Relation between parent and differencing disk (child).
But before we achieve this, we need to create a Windows Server Template. Let’s get started.
Steps
- Go through the installation process. I won’t show individual steps because I think everyone knows how to install an operating system.
- After the installation is done and the computer restarts to OOBE (The Out Of Box Experience), press CTRL+SHIFT+F3 to enter Audit Mode.
What is OOBE (The Out Of Box Experience)?
The Out Of Box Experience (OOBE) is the initial setup process you go through when you first start up a new device, such as a computer running Windows. Here’s what you can generally expect from the OOBE on a Windows device:
- Language selection: Choose the language for your device.
- Region selection: Select your geographical location.
- Keyboard selection: Choose the layout for your keyboard.
- …
What is Audit Mode?
Audit Mode lets you install programs, drivers, updates, etc. It lets you log into the device with the built-in administrator, so you don’t need to create any user.
Once you’re in Audit Mode, you’ll stay there. If you reboot your device, you’ll go back into Audit Mode, so you need to exit this mode when necessary.
After entering Audit Mode, I recommend installing Windows Updates. If Windows Updates need a reboot, you can safely do so because you’ll go back into Audit Mode after the reboot.
After installing the operating system, you can also install the software. But in my case, I didn’t need any specific software. Keep in mind that in the next step, we’ll use Sysprep, which can have some issues with apps installed from the Microsoft Store.
Now, we need to Sysprep our virtual machine. If the Sysprep window isn’t already open, you can open it from C:\Windows\System32\Sysprep
This option will remove the SID from the computer, generalize it, and then shut it down, ready for OOBE boot at the next startup.
NOTE: We prepared a Windows server template. Now repeat all the steps again for the Windows 11 Template.
Merging Checkpoints
After you’ve made both templates, we need to merge the checkpoints on both virtual machines.
Go to “Edit Disk” and choose the checkpoint located in the Templates folder. It will end with .avhdx or .avhd.
Choose “Merge to Parent Disk”.
Key Notes:
- Use Audit Mode to install programs, drivers, and updates. Audit Mode lets you log into the device without needing an extra user. It uses the built-in Administrator. After that, you can normally generalize and shut down the computer, and get ready for OOBE at the next start.
- To boot in Audit Mode, press CTRL+SHIFT+F3 during the OOBE (Out-of-box Experience) phase. The best time to boot into Audit Mode is after you install the OS.
- The Sysprep /generalize command removes unique information from your Windows installation so that you can safely reuse that image on a different computer
Conclusion
That’s all for this blog post. In the next blog post, we’ll learn how to create differencing hard disks from the templates we made today. Happy learning!
Github repository – Microsoft Home Lab