Provisioning Hyper-V virtual machines for a test environment Creating a new virtual machine which will be used as a template 1. In Hyper-V Manager, select New->Virtual Machine in the Actions pane. 2. The New Virtual Machine Wizard windows opens. Click Next.
3. Specify the Name for the machine, mine is W2K8_Base since I m going to be using this virtual machine as a template to provision future Windows 2008 machines for my test environment. Also specify the location to store the virtual machine files. Mine is C:\Virtual Machines. 4. Specify the amount of Memory you want to assign to this machine, this can be changed for each machine which you create from this template later.
5. Specify the network which this virtual machine will connect to. This can be changed later for each virtual machine which you create using this template. I m not specifying a network at this time. 6. Specify a name for the virtual hard disk file associated to this virtual machine and it s location.
7. Specify the method which you are going to use to install an operating system on the virtual machine. I m installing using an ISO file which I specified as per the snapshot below. 8. Click Finish on the summary page.
9. The virtual machine will be listed as below. 10. Right-click the machine and select Connect.
11. A remote control window opens up, click on the Start button to start the machine. Install Windows 2008R2 on the machine and once completed, follow the instructions below to remove the computer name and Security Identifier(SID) for the virtual machine before exporting it out and using it as a template to create future virtual machines. One of the issues which you will face if multiple systems have the same SID is that they will not be allowed to participate in the same domain. Once a system with a particular SID is registered as a member of a Windows domain, it will not accept another member with the same SID even if it has a different computer name.
Removing the SID from the virtual machine 1. Browse to %systemroot%\system32\sysprep and run the sysprep.exe tool. 2. Select Generalize and specify Shutdown in Shutdown Options and click OK.
3. Sysprep will start working and shutdown once completed.
Exporting the virtual machine 1. Once the virtual machine has shutdown, in Hyper-V Manager, select the machine and click Export. 2. Specify the location to export and click Export.
3. You can verify the status of the export operation in the Status column.
Provisioning a new virtual machine based on the template Exporting the virtual machine allows you to copy all the associated files for the virtual machines to another location(folder) in one operation, much like backing it up. You can then copy this folder to another Hyper-V machine and import the virtual machine into it in one operation as well. It s one way to manage disaster recovery of live virtual machines. But since we are looking at creating a template to use when provisioning new virtual machines quickly, you can just copy out the.vhd file located in the virtual machine directory and use a copy of it when you want to provision new machines. My template s virtual hard disk file location is C:\Virtual Machines\W2K8_Base\Virtual Hard Disks\W2K8_Base.vhd. In this example, I am going to provision a new virtual machine named SolveIT_DC, I will create the machine without a virtual hard disk first, so that the virtual machine folder is created for SolveIT_DC. Then I will copy the template vhd into this folder, rename it and attach it to SolveIT_DC. 1. In Hyper-V Manager, select New->Virtual Machine in the Actions pane. 2. The New Virtual Machine Wizard windows opens. Click Next.
3. Specify the Name for the machine, I am using SolveIT_DC since I m going to be provisioning a domain controller for my test environment. Also specify the location to store the virtual machine files. Mine is C:\Virtual Machines. 4. Specify the amount of Memory you want to assign to this machine, I m allocating 512MB.
5. Specify the network which this virtual machine will connect to. I m connecting to the Internal Virtual Network, which allows the virtual machines to communicate among themselves as well as the host machine. 6. Select Attach a virtual hard disk later. Click Next.
7. Click Finish on the summary screen. Once the machine is created, browse to the folder containing it s files. In my case, it is C:\Virtual Machines\SolveIT_DC. I then created a subfolder named Virtual Hard Disks and copied W2K8_Base.vhd into this folder and renamed it to SolveIT_DC.vhd. The next step is to attach this file to the virtual machine.
8. In Hyper-V Manager, select the virtual machine named SolveIT_DC and click on Settings in the Actions pane. 9. Select IDE Controller 0, Hard Drive and click Add as illustrated in the figure below.
10. Click on the Browse button and browse to the location of the vhd file, in my case it is C:\Virtual Machines\SolveIT_DC\Virtual Hard Disks\SolveIT_DC.vhd. Click Apply then OK to close the Settings window. You can start the machine and update some settings which you ll be prompted for in the mini setup which will run upon startup. You can then repeat these steps to provision more machines for your test or live environments.