Step-By-Step: How to Create a Windows 11 VM on Hyper-V via PowerShell

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

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 2GB -Generation 2 -NewVHDPath "C:\Windows11VM\Windows11VM.vhdx" -NewVHDSizeBytes 60GB

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

  3. Enter the following command to configure the network adapter for the VM:
    Add-VMNetworkAdapter -VMName "Windows 11 VM" -SwitchName "Default Switch"

    Note: This command configures the network adapter for the VM to use the default switch.

     
  4. Enter the following command to attach the Windows 11 ISO file to the VM:
    Add-VMDvdDrive -VMName "Windows 11 VM" -Path "D:\Sources\install.wim"

    Note: Replace D with the drive letter assigned to the Window 11 ISO file mounted in Step 2.
     

Step 5: Deploy the Virtual Machine

After configuring the VM settings, you can deploy the Windows 11 VM on Hyper-V. To do this, follow these steps:

  1. Enter the following PowerShell command to start the VM:
    Start-VM

     

  2. Once the VM is started, connect to the VM console by typing the following command:
    Connect-VMMServer -ComputerName "localhost" -Credential (Get-Credential)</li-code

     Note: This command connects you to the VM console using the local computer as the Hyper-V server.
     

  3. To install Windows 11 on the VM, follow the on-screen instructions. Select proper language, time zone, and keyboard options.
     
  4. After the installation is complete, shut down the VM by typing the following command:

    Stop-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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.