Hi there! When you were setting up a virtual machine, did you ever get stuck and scratch your head? You’re not the only one. I still remember the first time I tried it; let’s just say there were more “oops” than I’d like to admit. The good news is that I’ve been there, and I can show you how to use PowerShell to set up a Windows 11 VM on Hyper-V.

The next question you might have is “Why PowerShell?” Believe me, you’ll be a pro at setting up VMs once you get the hang of it. Also, it’s always good to have a cool trick handy, right? I’ll show you how to set up a VM whether you need it for work, testing, or simple fun. Let’s go on this trip together and setup Windows 11 VM on Hyper-V with PowerShell.

Why Set Up a VM with PowerShell?

Then you might ask, “What’s the big deal about PowerShell?” I can tell you, it’s like having a magic wand for your computer, but it’s more of a little blue box instead of a wooden stick. (Not a Tardis, sorry, Dr. Who fans.) You can make a VM, set it up, and have it going in no time with just a few commands. But it’s not just about speed. You can be precise, have full control, and automate jobs with PowerShell. This makes your life a lot easier.

I remember setting up several virtual machines for a job. It would have been a headache to do it by hand. It was like telling my computer, “Hey, do this for me, will you?” with PowerShell. And that was it, it was done. It was like having your own genie!

But here’s the really cool part: Standardization through automation is a big reason why people use PowerShell. It’s important to be able to do things over and over again in IT. We can do this with PowerShell, which makes sure that every VM setting is the same and free of mistakes. You know that every time you bake that cake, it will turn out just right because you have a plan.

Using PowerShell for your VM setups is a game-changer, no matter how experienced you are or how new you are to it. When you do it this way, you’ll be more efficient, in charge, and consistent. Are you ready to use your magic wand? Let’s do it.

Prerequisites

Before we dive into the magical world of setting up a VM, let’s make sure everything is ready. To begin, you will need these things:

  1. A Windows 10 or 11 Pro computer: This is our trusty horse, ready to take us through the process of setting up our VM. To get to Hyper-V, make sure it’s at least the Pro version.
  2. Make sure that Hyper-V is turned on for your machine. For me, it’s like letting the world of virtualization in.
  3. The Windows 11 ISO file is: This is a plan for the VM that we are going to build soon. It’s available for download on the Microsoft page.
  4. TPM chip and system that can handle virtualization: Make sure that your computer has a TPM chip and an engine that can handle virtualization. It’s like having the right engine and safety features to make the ride go smoothly.
  5. RAM: For running properly, your host OS needs at least 8 GB of RAM, and the VM needs at least 6 GB. I think you should have 16 GB of RAM so that both your host and VM work right.
  6. Finally, enough disk space. This is dependent on you, but at least 32 gb of free space is recommended for a useful system.

Lets get started

Setting up Hyper-V

Now, it’s time to start sounding like a robot. So, lets roll up our sleeves and get our fingers dirty. Setting up Hyper-V is our first step towards creating our Windows 11 VM. Here’s how we do it:

  1. Enable Hyper-V: Open PowerShell as an administrator. Then we will flip the virtualization engine on inside Windows with the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
  1. Verify Hyper-V Installation: Once the installation is complete, We need to make sure it all worked. We can do this by running the following command in the same window:
Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online
  1. Restart Your Machine: Because we are working with windows, We need to restart after installing hyper-v. Thanks windows. You can restart from your powershell console.
Restart-Computer -force

So that’s it for Hyper-V! Now that Hyper-V is set up, our Windows 11 VM can run on it. Setting up the stage for a big show is like that.

Creating the Windows 11 VM

Now that we have Hyper-V ready, it’s time to create our Windows 11 VM. Follow these steps, and you’ll have your VM up and running in no time:

  1. Open PowerShell as Administrator: Start by opening PowerShell with administrative privileges. It’s like putting on your wizard hat before casting a spell.
  2. Create a New Virtual Machine: The below command conjures up a new VM named “Windows11VM” with 6GB of RAM and a 50GB virtual hard drive. It’s like building the foundation of your virtual house.
New-VM -Name "Windows11VM" -MemoryStartupBytes 6GB -BootDevice VHD -NewVHDPath "C:\VMs\Windows11VM.vhdx" -NewVHDSizeBytes 50GB -Generation 2 -SwitchName "Default Switch" 
  1. Mount the Windows 11 ISO: Now, let’s attach the Windows 11 ISO to our VM. This step is like putting the key in the ignition, getting ready to start the engine.
Set-VMDvdDrive -VMName "Windows11VM" -Path "C:\Path\To\Your\Windows11.iso"
  1. Start the VM and Install Windows 11: Finally, start your VM and go through the Windows 11 installation. Connect to your VM using the Hyper-V Manager and proceed with the Windows 11 installation. It’s like watching your virtual house come to life, brick by brick.
Start-VM -Name "Windows11VM"

And there you have it! Your Windows 11 VM is now created and ready for action. It’s like having a brand-new playground to explore and enjoy.

What can we learn as a person today?

Do you remember exploring your toy box for your favorite toy as a kid? Always bottom, right? However, the thrill was finding all those great gadgets you forgot you had. Techies feel like way when fiddling with virtual machines. It’s our adult toy box full with electronic toys waiting to be played with.

Our VM is like an old toy box every time we use it. We may be looking for something specific, but we often find interesting new tricks or forgotten skills. Exploring and playing keeps us interested in tech and exercises our minds.

Having a place to experiment, make errors, and learn is crucial. It’s about exploring and having fun, not just making virtual machines. Please enjoy your virtual toy boxes and the excitement and growth they offer to your life as we navigate the tech world.

Additional Resources