How to create a Custom Hyper-V Quick Create VM Gallery
You might have seen that Hyper-V in Windows 10 got a new Quick Create Feature, this will open up a virtual machine gallery, which allows you to download different virtual machine images. For example the default image is a Windows 10 dev environment, which allows developers to quickly spin up a development environment with Visual Studio inside a Hyper-V virtual machine. If you want to create your own items in the Hyper-V VM Gallery.
To do that you simple have to do three things:
- Create a virtual machine image (a .iso or compatible .vhdx file)
- Create a gallery source (.json file) and create a gallery item (configuration inside the .json file)
- Add the gallery source to the VM Gallery UI
Create a Hyper-V virtual machine image
You can use a .iso (disk image) or a compatible .vhdx (virtual hard drive) file. If you create a VHDX file you will need to create a Hyper-V Generation 2 virtual machine and (usually) sysprep the virtual machine. The sysprep is not really needed, however, in most cases you want to do this. Check out my blog post about how to sysprep Hyper-V VMs. In addition the drive should also be at least 20GB.
Now make sure you store this where you can access it when you need it from the VM gallery. If you have multiple users using this image, all of them need access to it. You can place this on a web server, a file share or even a local disk.
Create a Hyper-V gallery source and create a Hyper-V gallery item
The next step is to create a new virtual machine gallery. This is basically a JSON file, which stores the VM images.
You can use my template:
For your own virtual machine image you will need the following information:
- LastUpdated (in the following format: yyyy-mm-ddThh:mm:ssZ
- Disk (uri to the vhdx or iso file)
- Logo (uri)
- Symbol (uri)
- Thumnail (uri)
The following notes:
To create the LastUpdated time, you can use the following command:
Get-Date -UFormat "%Y-%m-%dT%TZ" | clip.exe
To get the hashes of the files, you can use the following command:
Get-FileHash -Path .\TMLogo.jpg -Algorithm SHA256
You need to store this file also somewhere where the Hyper-V Manager can access it. So again, this can be a webserver, file share or local path.
Add the gallery source to the VM Gallery UI
The last thing you need to do, is to add the path of the virtual machine gallery to your Hyper-V machine. This can be done by adding a registry key to the machine you want to use it. If you want to use this on multiple machines, you can use GPOs or your device management to add the path to every machine.
Navigate to the following location:
Look for the GalleryLocations registry item and add your gallery path to the item.
I used the following sources: