How to Create a Hyper-V Template for Deployment

Microsoft HyperV Blog

How to Create a Hyper-V Template for Deployment

If you ever need to deploy Virtual Machines often a great time saving way is to create a VM Template for quick and easy deployment.

VM templates give you the advantage of a consistent configuration that is standardised format that is reusable.

To create a Hyper-V VM Template follow these steps;


 1. Open your SCVMM (Microsoft System Centre Virtual Machine Manager) console, click Hosts then Right Click and choose Create Virtual Machine.Create HyperV Template


 

2. Next, the Create Virtual Machine Wizard will start up. Choose Create the new virtual machine with a blank virtual hard disk and click Next.
Create HyperV Template 2


3. Now we need to give the VM a name and description. In this example I am using the Windows 2012 R2 operating system so the name and description are shown as such. As the Hyper-V host is Windows 2012 R2 as well, I can choose either Generation 1 or Generation 2 VM. Generation 2 VMs add the following new functionality;

  • PXE boot by using a standard network adapter
  • Boot from a SCSI virtual hard disk
  • Boot from a SCSI virtual DVD
  • Secure Boot (enabled by default)
  • UEFI firmware support

Create HyperV Template 14


4. We can now edit the VMs hardware configuration. Choose the appropriate hardware settings you wish, make sure to have selected your installation media and then selected Hyper-V for compatibility and click on Next.
Create HyperV Template 4


5. Select the Destination where the VM will reside.
Create HyperV Template 5


6. Now Select the Host to deploy to and then click Next.

Create HyperV Template6


7. On the Configure Settings tab, choose the location where the VM will keep its virtual hard disk and then click Next.Create HyperV Template 7


8. Select the appropriate network, adapter and virtual switch then click Next.
Create HyperV Template 8


9. You can now choose a few options including if you wish to Turn the machine on automatically and specify the operating system that you will install.Create HyperV Template 9


10. Check that the settings are correct, and when you are ready to, click Create.
Create HyperV Template 10


11. Now power on the VM if you have done so already, and install the operating system of your choice

Create HyperV Template 11


12. Now once you have installed the Windows Operating System, do not join the domain. Log on to the VM, open a command prompt and go to the Windows, System32, Sysprep folders then run sysprep.exe

Create HyperV Template 12


13. You will no be presented with the System Preparation tool. Make sure to check the Generalize checkbox as well as Shutdown in the shutdown options dropdown then click OK.

Create HyperV Template 13

Once the system has been prepared, the VM will power off.


14. Now that the VM has powered off, we need to convert it to a template. Highlight the powered off VM, right click and then Create and Create VM template to start the wizard.

HyperV Create VM Template


15. Next a warning is shown that you are about to convert this VM to a template. “Creating a template will destroy the source virtual machine “vm name“. The virtual hard disk of the virtual machine will be generalized to create the new template and any user data of the virtual machine may be lost. To prevent this, you can create a clone of “vm name”  before using it to create a template. 

Make sure you understand what you are committing this VM to and click Yes to continue.

Create HyperV Template 17


16. Now the Create VM Template Wizard starts. Give the template a name and description then click Next.

Create HyperV Template 18


17. Check you are happy with the hardware configuration then click Next.

Create HyperV Template 19


18. The Configure Operating System Tab we can change settings for the OS. Time Zones, whether you wish it to join a domain automatically or not, and any additional Operating System Roles or Features you wish can be configured here. Change what you need and then click Next.

Create HyperV Template 20


19. On the Select Library Server tab, choose one of your library servers and choose Next.

HyperV Create VM Template 22


20. Select the UNC Path location for the files to save to. Be mindful that other Hyper-V servers within your environment will require access to this folder.

Create HyperV Template 23


21. Finally, on the Summary Tab, you can view the script details to see the settings you have chosen. Confirm you are happy with the settings then click on Create. 

Create HyperV Template 24

Thats all there is to it. Your SCVMM and Hyper-V environment should now be preparing the selected VM and converting it to a template for consistent deployment to your virtual environment.