The Essential Guide to Hyper-V Windows 10 VMs

Creating and managing Hyper-V virtual machines (VMs) Windows 10 can be a useful way to solve problems for many people. Your virtual machine can be a great testing ground for new software or projects, and you can use it to run multiple operating systems in parallel.

Not a reader? Check out this related video tutorial!. Don’t see the video? Make sure your ad blocker is turned off.

In this tutorial, you will learn how to create and manage Hyper-V virtual machines (VMs) to get the most out of them with some of the best practices.

Ready? Read on to manage virtual machines like a pro!

Prerequisites

Since you’ll be creating a virtual machine, you’ll need to have a few things in place to follow

: A host machine running Windows 10 with Hyper-V

  • capabilities: This tutorial uses Windows 10 21H1 as the host machine. Note that the Hyper-V

feature requires Windows 10 Enterprise, Pro, or Education Edition.

An operating system ISO file

  • to install and a product key, if one is required: This tutorial uses a Windows Server 2019 ISO file, but you can also use another ISO

.

  • Sufficient storage space on the host machine for the virtual machine and its operating system: This tutorial allocates 50 GB of storage.

A minimum of 4 GB of RAM

  • : This tutorial allocates 8 GB of RAM for the virtual machine

.

  • A CPU processor that supports Intel Mode Extension or AMD-V virtualization extensions

.

Enable Hyper-V on the host computer

Now that you have all the prerequisites out of the way. You can enable Hyper-V on the host computer. Get several ways to enable the Hyper-V role on your host machine.

Why use multiple methods? You might need to use a specific method to enable Hyper-V in an enterprise environment. The methods shown below are the most commonly used.

Using

PowerShell

PowerShell is a scripting language that enables you to automate and manage Windows-based environments

.

The following steps also work in Windows 11 to

enable Hyper-V.

To enable Hyper-V by using PowerShell, follow these steps:

1. Open PowerShell as an administrator on your host machine, as you will need elevated privileges to enable Hyper-V.

2. Then, run the following

Enable-WindowsOptionalFeature command

to install the Hyper-V role on your host computer where: The -online parameter allows you to install the Hyper-V role

  • on a running operating system. The

-FeatureName Microsoft-Hyper-V parameter installs the Hyper-V role. And the –

  • All parameter installs all Hyper-V subfeatures.

In the following output, you can see that

  • the

RestartNeeded status says False, indicating that a restart is not required for the changes to take effect.

Restart the computer when the RestartNeeded state is True. But if you don’t see the RestartNeeded status, manually restart your computer for the changes to take effect.

3. Run the Get-WindowsOptionalFeature command below to verify that the Hyper-V role is installed.

If you get output like the following, where Status says Enabled it tells you that the Hyper-V role is enabled.

Using

the command prompt and DISM In addition to using

PowerShell, you can also use the command prompt and the Deployment Image Servicing and Management (DISM) tool to enable Hyper-V

.

The DISM tool is a command-line utility that services and prepares Windows images. These Windows images include Windows Recovery Environment, Windows Preinstallation Environment, and Windows Setup.

To enable Hyper-V with CMD and DISM:

1. Open the command prompt as an administrator on your host machine.

2. Then run the following command to install the Hyper-V role on your host machine where

: The /online parameter instructs the DISM tool

  • to service a running operating system. The /Enable-Feature parameter instructs the DISM
  • tool to enable a specific feature: Hyper-V ( /FeatureName:Microsoft-Hyper-V).
  • And the /All parameter instructs the DISM tool to enable all features of the specified package.

3. Restart your host machine to apply the changes.

4. Finally, run the following wmic command at the command prompt to get the version of Hyper-V Manager installed on your machine.

Below you can see that the latest installed version is 10.0.22000.708, but yours may be different.

Using the Windows

Feature Wizard

If you are a fan of installing tools through the GUI than in a command-line environment, you can also enable the Hyper-V role by using the Windows Feature Wizard. The Windows Feature Wizard provides a graphical user interface where you can enable or disable Windows features.

To enable Hyper-V by using the Windows Feature Wizard:

1. Search for features and click Turn Windows features on or off in the result, as shown below, to open the Windows Features window.

2. In the Windows Features window, scroll down the list of features and check the box next to Hyper-V, and the subfeatures will be checked automatically.

After checking the Hyper-V

box, click the OK button to enable Hyper-V and all its subfeatures.

3. Restart your computer to apply the changes.

4. Finally, find and open Hyper-V Manager on your host machine via the Start menu.

You will see the Hyper-V Manager window open if all goes well, as shown below.

Creating the first

Hyper-V

Windows 10 virtual machine

Now that you have Hyper-V installed on your Windows 10 machine, you’re ready to create your first virtual machine. But what makes virtual machines important? A virtual machine isolates an operating system and its applications from the underlying physical hardware.

Like a Docker container, a virtual machine encapsulates an entire operating system. But unlike containers, virtual machines provide each guest operating system with its own virtual hardware, including a virtual CPU, memory, storage, and network devices.

Related:Creating Your First Docker Windows Server Container

Related: Creating Your First Docker Windows Server Container

Virtual machines provide many benefits, including:

The ability to

  • run multiple operating systems in parallel on the same hardware. The ability to
  • test software and configurations in a secure, isolated environment.
  • The ability to run older operating systems on newer hardware.
  • Ease of management and portability of virtual machines.

To create a virtual machine using Hyper-V Manager:

1. Select the connected server in the left pane (ADMIN) and click New in the right pane under Actions: > virtual machine to start creating a new virtual machine.

You can see the Quick Create option below to create a virtual machine from a preconfigured list of virtual machine configurations. However, this option will not help you create a virtual machine with a specific configuration. And the wrong settings configured can lead to big problems. For diagnostic purposes, you should test all ways to create virtual machines.

2. Next, provide the following information for the name and location of the new virtual machine and click Next.

  • Name: Provide a descriptive name for the virtual machine (server01).
  • Location: Choose the location on the disk to store the VM files. It is recommended to store these files on a separate disk of your Windows operating system to minimize the risk of data loss.

This location stores all virtual machine files, including configuration, virtual hard disk, and snapshots.

Ensure that the location has enough free space for the virtual machine.

3. Keep the default build option for your virtual machine, Generation 1, and click Next.

If you ever plan to upload this VM to Azure, you should select Generation 2 instead. Why? Azure only supports UEFI-based boot, and generation 1 VMs use BIOS-based boot, while generation 2 VMs use UEFI.

Related:How to move a Hyper-V VM to Azure with Azure Migrate [Guide]

4. Now, allocate a startup memory for the virtual machine and click Next.

The amount of memory that you allocate depends on the following: The

  • operating system and applications that you plan to run on the virtual machine

.

  • The amount of memory available on the host computer.

You can allocate 32 MB to 5902 MB of memory, but the recommended memory to start with is at least 2000 MB, and then increase it as needed.

After allocating a startup memory, check the Use dynamic memory for this virtual machine option. This option allows the virtual machine to automatically adjust its memory usage as needed, based on the workload. Enabling this option reduces downtime and improves performance.

5. Select the Default Switch option, as you want your virtual machine to have network access, and click Next.

6. Next, configure the virtual hard disk as follows and click Next:

Leave the Create a virtual hard disk option selected.

  • Leave the Virtual Machine Name and Location values as they are automatically populated. You can choose an existing virtual hard disk if you already have one, or create a new one.
  • Specify the size of the virtual hard disk. We recommend that you have a minimum size of 20 GB to create a virtual hard disk.

7. Configure the operating system

installation options with the following: Select the

Install an operating system from

  • a bootable CD/DVD-ROM option, as this will install an operating system from an ISO file.

Select the image file (

  • .iso) and locate the ISO file

.

  • Click Next and you will see a Summary page with the settings specified for the virtual machine (step eight).

8. Finally, review the configuration summary and click Finish to create your virtual machine. But if you need to change any settings, click the Previous button instead.

After you create the virtual machine, you will see the virtual machine in

the Virtual Machines table in Hyper-V Manager, as shown below

.

Install an operating system on a

virtual machine

You have now successfully created the Hyper-V virtual machine. But right now, your virtual machine is empty and you don’t even have an operating system installed.

Select your VM (

server01) and click Start (lower right pane) to run your VM. Once it runs, click Connect to access your virtual machine in a separate window.

If you ever encounter the hypervisor not running error shown below, run the following command to enable the virtualization feature on your host. After running the command, restart the host for the changes to take effect. bcdedit /set hypervisorlaunchtype auto

Now, follow the on-screen instructions to install Windows on your virtual machine as you would on a physical machine

.

After the installation is complete, you can start using your virtual machine. Install applications and run them inside your virtual machine, but remember to back up your virtual machine regularly to avoid data loss.

Starting and stopping

virtual machines

Now that the virtual machine is running fully with an operating system, it’s time to take a look at managing virtual machines using Hyper-V Manager. In addition to creating virtual machines, Hyper-V Manager allows you to configure and manage virtual machines from a central location.

You’ll need to perform some basic tasks to keep your virtual machines running smoothly. These tasks include starting and stopping virtual machines and taking snapshots. But for now, you’ll start and stop your VMS and see how Hyper-V behaves while performing these tasks.

Select a virtual machine from the list and click Start (Ctrl+S) or Shut Down (Ctrl+P) in the right side pane to start or stop the selected virtual machine.

If you plan to start multiple virtual machines at once, you can select all of them and click Start. The virtual machines will start one after the other in the order in which they are listed.

Related:How to Configure Hyper-V Replication [Step by Step]

Saving

the State of a Virtual Machine

You can save the state of a virtual machine at any time, similar to putting a physical machine into hibernation. This behavior is useful if you need to close Hyper-V Manager or if you need to restart the computer.

Select your virtual machine from the

list and click the Save button in the right side panel to save the current state of the virtual machine to disk, and you can resume from that state later.

Creating

a Virtual Machine Checkpoint

A checkpoint is a snapshot of the current state of the virtual machine, including the configuration, disk state, and memory state of the virtual machine. Checkpoints are useful for taking snapshots of virtual machines at different times.

Let’s say you’re testing a new software application. If so, you can create a virtual machine checkpoint before you install the application. If the application does not work as expected, you can return to the checkpoint you created and start the virtual machine from that point.

Select the virtual machine from the

list and click Checkpoint (right pane) to create a checkpoint for the virtual machine.

Managing virtual machines

through

PowerShell

Hyper-V should be sufficient when managing virtual machines, but you can also use PowerShell to manage virtual machines. Why? This method is useful if you need to automate the creation or management of virtual machines. Your IaC and CI/CD pipelines will thank you!

Related:How to Create a Jenkins CI 1 CD Pipeline

. Run Get-Command below to view all available Hyper-V PowerShell cmdlets in a separate window (Out-GridView).

Related:

Hyper-V PowerShell Module: Doing More Below

is a long list of PowerShell cmdlets you can use to manage your virtual machines. Scroll through the list and choose a cmdlet that you want to try to run in PowerShell

.

2. Run the cmdlet that you selected in step one of PowerShell. For example, the following Get-VM cmdlet obtains and prints information about the virtual machine, as shown below.

Note the name of the virtual machine that you want to manage, in this case, server01.

3. Run the Checkpoint-VM command below to create a checkpoint for your VM (server01).

4. Finally, run the following command Get-VMCheckpoint below to get the checkpoint of your virtual machine (server01) in list format (Format-List).

You may like to know more about how to use a cmdlet. If so, run the Get-Help cmdlet followed by the cmdlet in question (Get-VM), as shown below.

Get-Help

Get-VM Related:Discover the unknown with the PowerShell command Get-Help

Conclusion

In this tutorial, you learned how to create and manage your Hyper-V virtual machines on Windows 10. You have mentioned some basic tasks that you need to perform to keep virtual machines running smoothly, such as starting and stopping virtual machines.

You have realized the importance of saving the state and creating checkpoints of your virtual machines as failsafe so that you can return to the good health of your virtual machine. And at this point, you now have a solid understanding of managing your virtual machines.

However, this tutorial is just the beginning! You can do much more with Hyper-V. So why not start creating a virtual network switch for your virtual machine? Or configure your virtual machine storage?

Contact US