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.
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:
Press the Windows key + R to open the Run dialog box.
Type msinfo32 and press Enter.
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.
Once you have confirmed that your system is compatible, you can proceed to enable Hyper-V on your Windows 11 machine. Here's how:
Press the Windows key + R to open the Run dialog box.
Type optionalfeatures and press Enter.
In the Programs and Features window, select Turn Windows features on or off in the left-hand pane.
In the Windows Features window, scroll down to Hyper-V and check the box next to it.
Click on OK and wait for the installation process to complete.
Once the installation is complete, click on Restart Now to restart your computer.
After enabling Hyper-V, you'll need to download the Windows 11 image via follow these steps:
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:
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.
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.
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.
Enter the following command to attach the Windows 11 ISO file to the VM:
Get-VMDvdDrive -VMName "Windows 11 VM"
Enter the following command to setup the boot order:
Set-VMFirmware -BootOrder "Windows 11 VM" -VMName "Windows 11 VM"
Enter the following command to specify the VM Key Protector configuration:
Set-VMKeyProtector -VMName "Windows 11 VM" -NewLocalKeyProtector
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.