Step-By-Step: How to Create a Windows 11 VM on Hyper-V via PowerShell
Published Mar 02 2023 12:04 AM 153K Views
Microsoft

As mentioned previously, Hyper-V is a virtualization technology that is not only useful for developers and IT administrators, but also for students. Using Hyper-V, students can install multiple operating systems and applications on a single physical machine. In a previous blog post, we covered steps to enable Hyper-V in Windows 11 via the Graphic User Interface (GUI). However, as many pointed out, there is a quicker way to accomplish this.

 

PowerShell is a more efficient and effective method for creating a virtual machine (VM) on Hyper-V, but what exactly is it? PowerShell combines a command-line shell, a scripting language, and a configuration management framework into a single, cross-platform tool for automating routine tasks. PowerShell is a scripting language that allows advanced computer users and IT professionals to quickly automate routine tasks related to the administration of computer systems (including Linux, macOS, and Windows) and their associated processes.

 

In this blog post, we'll show you how to use PowerShell to create a Windows 11 VM on Hyper-V. We'll walk you through the steps of installing Hyper-V, downloading the Windows 11 image, configuring the VM settings, and deploying the VM.

 

Lets get started.

 

Step 1: Check if your system is compatible

Before you can enable Hyper-V on your Windows 11 machine, you need to make sure that your system is compatible. Here are the system requirements for Hyper-V on Windows 11:

To check if your system is compatible, follow these steps:

  1. Press the Windows key + R to open the Run dialog box.

  2. Type msinfo32 and press Enter.

  3. In the System Information window, scroll down to the "System Summary" section and look for the Hyper-V Requirements line. If it says "Yes", then your system is compatible.

 

Step 2: Enable Hyper-V on Windows 11

Once you have confirmed that your system is compatible, you can proceed to enable Hyper-V on your Windows 11 machine. Here's how:

  1. Press the Windows key + R to open the Run dialog box.

  2. Type optionalfeatures and press Enter.

  3. In the Programs and Features window, select Turn Windows features on or off in the left-hand pane.

  4. In the Windows Features window, scroll down to Hyper-V and check the box next to it.
     
    Enabling Hyper-V in the Windows Features dialog boxEnabling Hyper-V in the Windows Features dialog box
     

  5. Click on OK and wait for the installation process to complete.

  6. Once the installation is complete, click on Restart Now to restart your computer.
     

Step 3: Download the Windows 11 image

After enabling Hyper-V, you'll need to download the Windows 11 image via follow these steps:

  1. Download the Windows 11 ISO file.
  2. Once downloaded, mount the Windows 11 ISO file by right-clicking the downloaded file and selecting Mount.
  3. Wait for the ISO file to mount, and then take note of the drive letter assigned to the mounted ISO file.

 

Step 4: Configure the VM settings

Once Hyper-V has been enabled and the Windows 11 image has been downloaded, the next step is to set up the VM. This can be done in PowerShell via the following steps:
 

  1. Find PowerShell in the Windows 11 search box and select Run as an administrator.
     
  2. Type the following command to create a new VM:
    New-VM -Name "Windows 11 VM" -MemoryStartupBytes 4GB -Generation 2 -NewVHDPath "C:\Windows11VM\Windows11VM.vhdx" -NewVHDSizeBytes 60GB

    Note: This command creates a new virtual machine with the name "Windows 11 VM" 4GB of RAM, and a virtual hard disk of 60GB. Feel free to modify as needed.
     

  3. Type the following command to assign a processor count to the VM:

    Set-VM -Name "Windows 11 VM" -ProcessorCount 4

    Note: Modify processor count required.

     
  4. Enter the following command to setup the Windows 11 ISO file:
    Add-VMDvdDrive -VMName "Windows 11 VM" -Path "D:\Downloads\Win11_22H2_English_x64v2.iso"

    Note: Replace D with the drive letter assigned to download folder of the Window 11 ISO file.
     

  5. Enter the following command to attach the Windows 11 ISO file to the VM:

    Get-VMDvdDrive -VMName "Windows 11 VM"

      

  6. Enter the following command to setup the boot order:

    Set-VMFirmware -BootOrder "Windows 11 VM" -VMName "Windows 11 VM"

     

  7. Enter the following command to specify the VM Key Protector configuration:

    Set-VMKeyProtector -VMName "Windows 11 VM" -NewLocalKeyProtector

     

  8. Enter the following command to enable the virtual TPM:

    Enable-VMTPM -VMName "Windows 11 VM"

     

Further resources surrounding the enablement of these resources can be found here: Hyper-V Resource Settings

 

With your Windows 11 VM now configured, load Hyper-V Manager and start your VM.

 

Harnessing PowerShell to create a Windows 11 VM on Hyper-V is a straightforward process that can save students time and effort to setup the solution. Following the steps outlined can enable you to create a fully functional Windows 11 VM on Hyper-V quicker than using the GUI and is particularly useful for those that need to deploy multiple VMs quickly and efficiently. PowerShell is an awesome tool you can harness to automate the entire process and ensure that each VM is configured correctly.
 
How to Create a Windows 11 VM on Hyper-V via PowerShellHow to Create a Windows 11 VM on Hyper-V via PowerShell

19 Comments
Co-Authors
Version history
Last update:
‎Oct 13 2023 11:49 AM
Updated by: