Back

Creating a Hyper-V Template

Creating a HyperV template to quickly deploy new VMs can save time on spin up and updating You can set up hyperV templates preinstalled with appli...

6 min read
Published on Mar 1, 2016
creating-a-hyper-v-template

Creating a Hyper-V template to quickly deploy new VMs can save time on spin up and updating. You can set up hyper-V templates pre-installed with applications and Windows features just as a WDS or PXE image would provide a consistent configuration for every deployment.

In this blog, I’ll be showing you how to manually create a new VM in Hyper-V, prepare the VM after imaging and then export/import as a template on Hyper-V 2016 Preview, with a Server 2012 R2 DataCenter VM.

First, we’ll create our VM template:

hyperv1

Give the VM a recognizable name. When creating the VM and specifying a name and location, leaving the “Store the virtual machine in a different location” box unchecked will store the VM configuration and VHD files in the configured location in the “Hyper-V Server settings.” To select a different location, check this box and you will be prompted to specify locations for files in the next screens.

hyperv2

Select your preferred generation. This decision has no impact on the process, but keep in mind this cannot be changed after deployment. Additionally, if you plan to import this virtual machine into Azure, at the time of this blog, only Generation 1 VMs are compatible with Azure services. A common scenario for choosing Generation 2 virtual machines would be if you plan to migrate VMs between other Server 2012 R2 (or Windows 8.1/10 Pro or Enterprise) Hyper-V servers.

Additional information about the differences between generations is located here:

hyperv3

Assign your memory. All VMs deployed with this template will start with this amount. It can be changed after deployment.

hyperv4

Select your network connection. Again this can be changed after deployment or additional NICs are added to the VM.

hyperv5

And finally specify your disk size. I find 80GB to be suitable for the base OS and some smaller apps. For any virtual machines that will be running applications such as SQL, SCCM, SCOM, etc., I tend to add a second data disk post deployment of the template. Note that disk size for the system disk and any data disks can be modified after deployment.

hyperv6

Post setup of the VM, don’t forget to adjust the amount of virtual processors to increase performance during the OS install process. At least 2 processors should be used for the base install and updates to reduce the amount of time the process takes. This processor count can be adjusted up or down after OS install.

hyperv7

Now proceed with the install of the OS as you would any other server. Once setup is completed, perform any updates you wish to be included in the template. Do NOT domain join the server or activate it. This data will be wiped during the sysprep action we’ll be taking next. Do not worry about changing the name; that will also be reset. Some options you can change that carry over when deployed from the template include:

  • Remote Desktop Settings
  • IE Enhanced Security
  • Time zone
  • Local Users and Groups
  • Update Settings (overwritten by GPO if update GPOs exist)
  • Install of common freeware apps like Notepad++, FileZilla, WinSCP, etc.
  • Some Windows Features such as .Net 3.5

Once you have your updates, settings and apps where you want them on the VM, navigate to C

and run SysPrep.exe

hyperv8

You’ll want to use the Out-of-Box Experience and be sure to check the box to Generalize. In the shutdown options, select Shutdown. The system will enter a generalized state much like when purchasing a PC from a retailer and shut down once completed so we can export the template.

Once the VM is completely shut down, right click on it and select “Export”:

hyperv10

Select your export location and click Export.

Optionally, you can choose to simply copy and paste the template VHD and rename it each time you stand up a new VM. Choosing the export option allows for rapid cloning of the VM Configuration file, which may prove useful if you plan to set up numerous VMs with the same hardware specifications. The option of a full export is laid out below: hyperv11 hyperv12 Hyper-V will now go through the process of copying the VM virtual hard drive and configuration to the destination you selected. Once the process is completed, you can move the exported folder to any other Hyper-V host running the same version as where you created the VM and import the image for use. You can leave the VM alone and turn it back on later to apply the most recent updates and repeat the sysprep process to keep an always up to date Hyper-V template. You can also now delete the VM you created (be sure to remove the virtual hard drive as well) as it’s no longer needed beyond use as a gold image or master image if you wish. Importing the template seems just as simple as exporting, but there some additional items that need changed after import. First we need to import the template into Hyper-V. hyperv13 Select the folder you exported the template VM into. hyperv14 Select “Copy the virtual machine” to generate a new ID. hyperv15 Specify the location of the VM files after the copy and the location of the VHD. hyperv16 Once the import operation is completed, rename the VM to something that better suits the server or what the server name will be. Once this is completed, you’ll need to navigate to the folder you selected for the operation to copy the VHD to (commonly the default location of all VHD files on Hyper-V) and rename the VHD. During the import service Hyper-V makes (essentially) an exact replica of the template to include file names for disks. You’ll want to rename this copied disk to match the server name. If you attempt to use the template again and do not rename the disk, the operation will fail due to a file with the template disk name already existing. hyperv17 Don’t forget to edit the VM after renaming the disk and remap the VM disk to this new file name. hyperv18 After that, it’s simply a matter of powering the VM on, going through the initial configuration, and you have a fully updated VM that’s been deployed in 5 minutes.

In a future post, we’ll cover automating this process through PowerShell.

Jeremy Sheehan is a Cloud Specialist at Agile IT, and runs many of our AgileAscend projects.  To hear more of our tech team’s wisdom, check out our blog here, and to speak with us regarding Hyper-V (or anything else!) you can contact us here.

This post has matured and its content may no longer be relevant beyond historical reference. To see the most current information on a given topic, click on the associated category or tag.

Related Posts

Risks of not using a CMMC RPO

The Risks of Not Using a CMMC RPO for Compliance and Certification Readiness

A CMMC RPO helps organizations prepare for certification and avoid compliance failures. Learn why working with an RPO is essential for achieving CMMC compliance.

Mar 20, 2025
8 min read
CMMC 2.0 Require GCC High for Compliance

Does CMMC 2.0 Require GCC High for Compliance?

Does CMMC 2.0 require GCC High? Learn the cloud options for compliance, data security, and protecting CUI under NIST 800-171 and DFARS.

Mar 17, 2025
10 min read
Office 365 License Comparison: Business Plans Vs. E5, E3 and E1

CMMC RPO vs a C3PAO: Understanding Their Roles in Compliance

Understanding the difference between an RPO and a C3PAO is crucial for CMMC compliance. Learn why they should be separate and how an RPO helps prepare for certification.

Mar 15, 2025
6 min read
Can You Meet CMMC with Google Workspace?

Can You Meet CMMC with Google Workspace?

Is Google Workspace CMMC compliant? Learn about its DFARS, NIST 800-171, and ITAR limitations and how migrating to GCC High ensures full compliance.

Mar 4, 2025
7 min read
Is Maintaining a GCC High Tenant Worth It for Non-Government

Evaluating the Need for a GCC High Tenant in Non-Government Organizations

Explore whether maintaining a GCC High tenant is necessary for organizations not involved in government work. Understand the pros and cons, costs, and compliance considerations.

Feb 25, 2025
7 min read
Top 10 Reasons to Partner with an MSP for Security and Compliance

Top 10 Reasons to Partner with an MSP for Security and Compliance

Discover why partnering with an MSP for security and compliance is critical for organizations navigating FAR CUI and CMMC requirements.

Feb 21, 2025
8 min read

Ready to Secure and Defend Your Data
So Your Business Can Thrive?

Fill out the form to see how we can protect your data and help your business grow.

Loading...
Secure. Defend. Thrive.

Let's start a conversation

Discover more about Agile IT's range of services by reaching out.

Don't want to wait for us to get back to you?

Schedule a Free Consultation

Location

Agile IT Headquarters
4660 La Jolla Village Drive #100
San Diego, CA 92122

Secure. Defend. Thrive.

Don't want to wait for us to get back to you?

Discover more about Agile IT's range of services by reaching out

Schedule a Free Consultation