Hyper-V template for Intune
Want to test out autopilot device preparation in Hyper-V, but don’t know where to start? In this post, I’ll take you through the steps needed to create a Hyper-V virtual machine template for Intune.
Prerequisites
- Windows 11 or Windows 10 (pro or enterprise)
- Hyper-V installed
- Windows 11 ISO (pro or enterprise), with at least the may 2024 updates
Create a new virtual machine
- Open Hyper-V Manager
- Click on
Action
and thenNew
andVirtual Machine
- Click
Next
- Choose a name for the virtual machine, for example,
IntuneTemplate
- (optional) Choose a different location for the virtual machine
- Click
Next
- Choose
Generation 2
- Click
Next
- Assign at least 4GB of memory, (more is probably faster)
- Click
Next
- Select the virtual switch you want, I picked
Default Switch
- Click
Next
- Create a new virtual hard disk, size needs to be at least 30 GB, change the location if needed
- Click
Next
- Install an operating system from a bootable image file, select the Windows 11 ISO
- Click
Next
- Click
Finish
- Right-click on the new virtual machine and click
Settings
- Go to
Security
and enableEnable Secure Boot
andEnable TPM
(needed for autopilot) - Click
OK
- Right click on the virtual machine and click
Connect
- In the new window, click on
Start
and press any key to boot from the ISO - Install Windows 11 as you would on a physical machine (next, next, …)
Don’t go through the OOBE (setup steps)! instead continue with the next step in this guide.
Prepare the virtual machine
You virtual machine should now be in the Windows 11 setup screen, where you can pick your region.
- Press
Shift
+F10
to open a command prompt - Run the following commands to prepare the virtual machine for autopilot:
cd c:\Windows\System32\Sysprep
Sysprep.exe /oobe /generalize /shutdown /mode:vm
This will prepare the machine to be able to be cloned. When this command finishes it will shut down the virtual machine.
Don’t start the virtual machine again! Instead, continue with the next step.
Convert the disk
- Open Hyper-V Manager
- Select the virtual machine you just created
- Click
Edit Disk
- Click
Next
- Locate the virtual hard disk file you created earlier
- Click
Next
- Select
Convert
and clickNext
- Choose
VHDX
and clickNext
- Choose
Dynamically expanding
and clickNext
- Choose a location for the new disk, and click
Next
- Click
Finish
Template created
You now have a disk image that you can use to create new virtual machines that will start in the OOBE (setup) screen.
All done!
Create a new virtual machine from the template
I’m not going to explain how to create a new virtual machine from this template as Steven Weiner has already created a great video on this topic.
His script is available in his GitHub repository.
Conclusion
You now have a Hyper-V template that you can use to test autopilot device preparation. Since this template is generalized, you can create multiple virtual machines from it.