When working in virtual environments, we always create virtual machines. When we are in an environment where we need to create many virtual machines it’s very difficult to go through the same VM creation process.
So in this article, I will explain how to create a template so that we don’t need to create machines from scratch. We will always have the latest VM with all fully deployed security patches.
To Start creating this follow the following steps
Open Hyper-V Manager
Open the virtual machine you want to create a template of and go to C:\Windows\System32\Sysprep.
Run the file, sysprep.exe and click on Generalize check box and select shutdown from shutdown options and then click on OK.
Once done, the machine will be shutdown automatically.
Now right click on the VM where you have run the Sysprep command and select Export.
Enter the path where you want to save the template and click ok.
Now, you have the template saved, let see how we can create new VM using template.
Create new VM without the disks, select New then choose Virtual Machine, configure the machine, selecting the same generation as the template you created, but CPU, memory and networking settings can be different.
When you get to the Connect Virtual Hard Disk option, select Attach a virtual hard disk later, click Next and then Finish.
Now go to the template folder and copy the template HDD file to a location where your active VMs HDD are placed.
Rename the file you have just copied for your new virtual machine.
Now go to the newly created virtual machine settings (that was created without HDD) and select the VHDD which you have copied from templete folder and click OK.
You can now boot the virtual machine, once it has finished detecting devices it will run through a short wizard to select the language, license terms and set the administrator password, and you’ve got a patched virtual machine deployed.