How to create a Custom Hyper-V Quick Create VM Gallery

This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.

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, like Windows 10 or Ubuntu. For example, the default image is a Windows 10 dev VM, which enables developers to quickly spin up a development environment with Visual Studio. But you can also add your own virtual machine templates in the Hyper-V VM Gallery.

 

To do that, you 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

 

 

Sysprep Virtual Machine.pngSysprep Virtual Machine

 

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 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

 

Custom-Hyper-V-Quick-Create-VM-Gallery.jpgHYPER-V QUICK CREATE VM GALLERY

 

The next step is to create a new virtual machine gallery. This is a JSON file, which stores the VM images.

You can use my template:

 

 

 

 

 

{ "images": [ { "name": "Thomas Maurer Awesome Image", "version": "10.0.16299", "locale": "en-US", "publisher": "ThomasMaurer.ch", "lastUpdated": "2018-05-22T23:16:43Z", "description": [ "This is Toms Awesome Image!", "\r\n\r\n", "Check out more on: https://www.thomasmaurer.ch for any additional details.", "\r\n\r\n" ], "config": { "secureBoot": "true" }, "requirements": { "diskSpace": "28290580480" }, "disk": { "uri": "https://download.microsoft.com/download/1/8/2/182A2CF7-B1B8-4CEC-876A-E883FA1D671B/HyperFeed.zip", "hash": "sha256:7786a0b2ff0d726e095fbcdaded8e2bad8f53b72dda2dd19c7005f3540b5b927", "archiveRelativePath": "HyperFeed.vhdx" }, "logo": { "uri": "https://www.thomasmaurer.ch/TMLogo.jpg", "hash": "sha256:259F7864136D8A238B478CA4BB6F0AE8EF94AA1D31320CD1EA6AD9AE32B08C72" }, "symbol": { "uri": "https://www.thomasmaurer.ch/TMLogo.jpg", "hash": "sha256:259F7864136D8A238B478CA4BB6F0AE8EF94AA1D31320CD1EA6AD9AE32B08C72" }, "thumbnail": { "uri": "https://www.thomasmaurer.ch/thumbnail.jpg", "hash": "sha256:8483670D97078ECF0FA278113C7BAD169448C6C8400B56AACEF0C5D311AB6373" }, "details": [ { "name": "Edition", "value": "Windows 10 Tom Edition" }, { "name": "Copyright", "value": "Copyright (c) Thomas Maurer. All rights reserved." }, { "name": "License", "value": "Evaluation: https://www.thomasmaurer.ch" } ] } ] } { "images": [ { "name": "Thomas Maurer Awesome Image", "version": "10.0.16299", "locale": "en-US", "publisher": "ThomasMaurer.ch", "lastUpdated": "2018-05-22T23:16:43Z", "description": [ "This is Toms Awesome Image!", "\r\n\r\n", "Check out more on: https://www.thomasmaurer.ch for any additional details.", "\r\n\r\n" ], "config": { "secureBoot": "true" }, "requirements": { "diskSpace": "28290580480" }, "disk": { "uri": "https://download.microsoft.com/download/1/8/2/182A2CF7-B1B8-4CEC-876A-E883FA1D671B/HyperFeed.zip", "hash": "sha256:7786a0b2ff0d726e095fbcdaded8e2bad8f53b72dda2dd19c7005f3540b5b927", "archiveRelativePath": "HyperFeed.vhdx" }, "logo": { "uri": "https://www.thomasmaurer.ch/TMLogo.jpg", "hash": "sha256:259F7864136D8A238B478CA4BB6F0AE8EF94AA1D31320CD1EA6AD9AE32B08C72" }, "symbol": { "uri": "https://www.thomasmaurer.ch/TMLogo.jpg", "hash": "sha256:259F7864136D8A238B478CA4BB6F0AE8EF94AA1D31320CD1EA6AD9AE32B08C72" }, "thumbnail": { "uri": "https://www.thomasmaurer.ch/thumbnail.jpg", "hash": "sha256:8483670D97078ECF0FA278113C7BAD169448C6C8400B56AACEF0C5D311AB6373" }, "details": [ { "name": "Edition", "value": "Windows 10 Tom Edition" }, { "name": "Copyright", "value": "Copyright (c) Thomas Maurer. All rights reserved." }, { "name": "License", "value": "Evaluation: https://www.thomasmaurer.ch" } ] } ] }

 

 

 

 

 

For your virtual machine image, you will need the following information:

 

  • Name
  • Publisher
  • Description
  • Locale
  • Version
  • LastUpdated (in the following format: yyyy-mm-ddThh:mm:ssZ
  • Disk (uri to the vhdx or iso file)
  • Logo (uri)
  • Symbol (uri)
  • Thumbnail (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 web server, file share, or local path.

 

Add the gallery source to the VM Gallery UI

 

 

Hyper-V-Gallery-Location-registry-key.jpgAdd 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 computer you want to use it. If you're going to use this on multiple machines, you can use GPOs or your device management to add the path to every computer.

 

Navigate to the following location:

 

 

 

 

 

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\

 

 

 

 

 

Look for the GalleryLocations registry item and add your gallery path to the item.

 

I used the following sources:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.