How to create Virtual Machine using Hyper V?

by | Mar 6, 2024 | Computer, Windows | 0 comments

Hyper-V, Microsoft’s hardware virtualization product, enables users to create and run a software version of a computer, called a virtual machine. Every virtual machine functions as an entire computer, executing its own operating system and applications. Hyper-V makes it possible for you to run multiple operating systems simultaneously on a single physical machine, separating them into distinct virtual machines for various tasks or projects.

This feature is incredibly useful for IT professionals and developers who need to test applications across different environments, manage server resources more efficiently, or consolidate hardware to save on physical space and energy costs. Hyper-V’s ability to provide a scalable, flexible virtualization platform is a cornerstone for modern IT infrastructure, offering a seamless way to elevate your computing resources to meet the dynamic demands of today’s digital landscape.

This guide takes you through the process of setting up multiple VMs in Hyper-V, ensuring that you have the tools needed to expand your network’s capacity with ease.

Getting Started with Hyper-V

Before diving into the creation of multiple VMs, ensure that Hyper-V is enabled on your Windows server or workstation. You’ll need a system running Windows 10 Pro, Enterprise, or Education, or a Windows Server version that supports Hyper-V. Access the “Turn Windows features on or off” menu to enable Hyper-V and reboot your system to complete the setup.

  1. Click Start Menu and type “Turn Windows Features On or Off” and press Enter. start-menu-windows-features
  2. In the Windows Features window scroll down until you find “Hyper-V.
  3. Check the box next to “Hyper-V” to enable it.
  4. Click “OK” to apply the changes. Windows will now search for the required files, apply the changes, and may request to restart your computer. start-menu-windows-features-enable

Step 1: Launch Hyper-V Manager

Open Hyper-V Manager from the Start menu. This is your control center for managing VMs and their associated resources. start-menu-hyper-v

Step 2: Configure Your Virtual Network

For VMs to communicate with each other and the internet, set up a virtual switch:

What type of virtual switch do you need to choose?

External Virtual Switch: Connects virtual machines to a physical network using the host’s network adapter. This allows VMs to access external resources, such as the internet or a local network, just as if they were physically connected to the network. It bridges the gap between virtual and physical networks, enabling direct communication from VMs to external network devices.

Internal Virtual Switch: Creates a communication environment between virtual machines on the same host and between the host machine itself, without providing access to the external network. This is useful for isolated network environments needed for testing or development purposes, where external network access is unnecessary or needs to be strictly controlled.

Private Virtual Switch: Allows communication only between virtual machines on the same Hyper-V host, excluding the host machine itself. This setup is ideal for creating a completely isolated networking environment, useful for scenarios where VMs need to communicate with each other without any direct access to the external network or the host network.

  1. In Hyper-V Manager, click on “Virtual Switch Manager” from the right pane. hyper-v-virtual-switch
  2. Select “New virtual network switch,” choose the type (external, internal, or private), and click “Create Virtual Switch.” hyper-v-virtual-external-switch
  3. Name your switch, configure its connection type, and apply the settings. hyper-v-virtual-external-switch-create

Step 3: Create the First Virtual Machine

Now, let’s create your first VM:

  1. In Hyper-V Manager, right-click on your computer’s name and select “New” -> “Virtual Machine.” virtual-machine-new
  2. The New Virtual Machine Wizard will launch. Click “Next” to begin the configuration process. virtual-machine-new-next
  3. Enter a name for your VM and choose its storage location. virtual-machine-new-name-location
  4. Specify the generation of the VM. Generation 2 offers more features but ensure your operating system supports it. virtual-machine-new-generation
  5. Assign memory to the VM. Enable “Dynamic Memory” for more efficient resource use. virtual-machine-new-memory
  6. Connect the VM to the virtual switch you created earlier. virtual-machine-new-switch
  7. Create a virtual hard disk. Specify the name, location, and size. virtual-machine-new-size
  8. Install an operating system from a bootable CD/DVD or an ISO file. virtual-machine-new-source
  9. Review your settings and click “Finish” to create the VM. virtual-machine-new-finish

Step 4: Duplicate Virtual Machines

After setting up your first VM, you might want to create additional ones without going through the entire process manually. Hyper-V doesn’t natively support cloning VMs in the GUI, but you can accomplish this by copying the first VM’s virtual hard disk (VHD or VHDX file) and creating new VMs using these copies.

  1. Locate the VHD/VHDX file of the VM you want to clone.
  2. Copy the file and rename it for your new VM.
  3. Create a new VM following the steps above, but instead of creating a new virtual hard disk, select “Use an existing virtual hard disk” and choose the copied VHD/VHDX file.

Step 5: Automating VM Creation

For creating multiple VMs, PowerShell scripts can be a time-saver. Here’s a basic script to create a new VM:

PowerShell code

New-VM -Name “VMName” -MemoryStartupBytes 2GB -NewVHDPath “C:\VMs\VMName.vhdx” -NewVHDSizeBytes 40GB -SwitchName “YourVirtualSwitch”

Modify the script parameters for each VM you want to create, saving time and ensuring consistency across your VMs.

Best Practices for Managing Multiple VMs
  • Consistent Naming Convention: Use a naming convention for your VMs and VHD files to keep your environment organized.
  • Resource Allocation: Monitor the performance of your VMs and adjust resources as necessary to optimize efficiency.
  • Regular Backups: Implement a backup strategy for your VMs to prevent data loss.

Creating multiple VMs in Hyper-V can significantly enhance your network’s flexibility and scalability. By following these steps, you can efficiently set up a virtualized environment that supports your organization’s needs. Whether manually configuring each VM or leveraging PowerShell for automation, the power of Hyper-V simplifies the management of a complex infrastructure.

Related Articles

How to Recover Lost Data?

How to Recover Lost Data?

Losing data can feel like a punch to the gut, whether it's a report you've worked on for weeks or years of precious family photos. But before you...