Building Your Local Lab: Creating your virtual machines

**DISCLOSURE: While I am contracted to Microsoft Corporation, I am not an employee. The articles that I write are not meant to represent the company, nor are they meant to represent me as an employee or spokesman for the company. As has always been the case, all articles on this website represent me and nobody else.

**NOTE: All of the command line entries in this article are performed in PowerShell. To differentiate between the PowerShell cmdlets and Command Line Interpreter commands, the PowerShell cmdlets are in blue, and the Commands are in black.

Windows10In my previous articles in this series, we installed Hyper-V on our Windows 10 machines, and then we configured the infrastructure to work. Now that we have our plate prepared with all of the sides and garnishes, let’s put some meat on it. In other words… let’s build a couple of virtual machines.

Prerequisite knowledge

In my last article we created a virtual switch (also known as a virtual network) that is connected as an External switch. It is external because we tethered it to a network interface card (NIC), which is presumably connected to the outside world. That could be a local area network, or in most cases it could be the Internet. In my home environment, I have a virtual switch connected to my Wi-Fi adapter, and so any virtual machine that I connect to it will connect to my local router (which, in addition to providing access to the Internet, also acts as a DHCP Server and distributes dynamic IP addresses).

As my long-time readers will know, I like to use Windows PowerShell instead of the GUI consoles to perform as many creating activities as I can. I do most of my actual management and day-to-day work in the GUI, but I like to create in scripts, for the simple reason that I create repeatable commands. If I run Script A 500 times, then given the same ambient conditions it will perform identically 500 times. If I perform the same feat by hand 500 times, there is a better than average chance that I will make a mistake at some point. And so, I will do everything in PowerShell first; in a future article, I might go through the GUI steps for those of you who are still unwilling to come over to the script side.

I have created a directory on my D: drive called d:\ISOs into which I have copied the ISO files for both Windows Server 2019 and Windows 10 (Business Editions). The original filenames are:

  • en_windows_server_2019_updated_feb_2021_x64_dvd_277a6bfe.iso; and
  • en_windows_10_business_editions_version_20h2_updated_feb_2021_x64_dvd_4d532d82.iso

For what I have planned, those names will be a bit much, and so I am renaming the files:

  • Server2019.iso; and
  • W10-20h2.iso

Creating a virtual machine in our default location

In my previous article, I mentioned that Hyper-V has default file locations for both the virtual machine files and for the virtual hard disk files. Whether you have changed those locations (per instructions in the article) or not, the script we will use will build the virtual machines in whatever default file locations you have configured.

**Remember that you will need a sufficiently sized virtual hard drive on which to install your operating system, as well as any applications and data you need. Make sure to consult your OS provider for initial sizing, and then do the proper calculations for anything in addition to the OS.

I want to create a VM with the following parameters:

  • Name: Win10-VM1
  • Memory: 2GB RAM
  • Generation: Generation 1
  • Default boot device: IDE hard drive
  • Virtual network: BehikeWiFi
  • VHD size: 40GB
  • VHD Name: Win10-VM1-c.vhdx

Here is the cmdlet with all of the switches to do just that. Please note that this cmdlet must be done in a PowerShell instance with Administrator credentials.

New-VM -Name Win10-VM1 -MemoryStartupBytes 2GB -Generation 1 -BootDevice IDE -SwitchName BehikeWiFi -NewVHDSizeBytes 40GB -NewVHDPath “d:\HyperV\Virtual Hard Disks\Win10-VM1-c.vhdx”

The next thing I want to do is to connect the Windows 10 ISO file to the VM, so that when I boot it up we will install the operating system. Run the following cmdlet:

Set-VMDvdDrive -VMName Win10-VM1 -Path “d:\ISOs\W10-20h2.iso”

Note that in both cmdlets I am putting quotation marks around the file names and locations. If neither filename nor folder path have any spaces this is not necessary, but it is a good habit to get into.

Starting (and installing) our VM

We should be ready to start the virtual machine, so let’s run the following:

Start-VM –name Win10-VM1

Alright! Now that we have done so much work in PowerShell, let’s relax a little and move on to the GUI.

In the Start menu, navigate to Windows Administrative Tools – Hyper-V Manager. When you click it, you will have to accept a UAC prompt.

Now that you have Hyper-V Manager running, it should be connected to your local machine. If you just started with Hyper-V on this machine, there will be a single virtual machine, the one you just created. Your screen will look like this one (minus the extra VMs I have):


When you select the VM you will notice a few things. Firstly, it is running, but hardly using any CPU. There is (in the middle of the screen) a Checkpoint for the VM which was automatically created when we started the VM. This is a good way to test things, and then revert back. At the bottom, you will see a screen thumbnail of what is actually on the screen of the VM… in our case, the first screen of the Windows 10 installation process. Remember when we selected the hard drive as the primary boot device? Well, if there is no operating system on the hard disk, it defaults to the next boot option… the virtual DVD of Windows 10 that we inserted.

Right-click the machine you created, and click Connect. That will open a Virtual Machine Connection window, in which your OS is ready for you to install.

I am not going to go through the steps of installing the operating system; either you are installing Windows 10, or Windows Server, or any of myriad flavours of Linux. Whatever OS it is, go ahead and install it. Go… I’ll wait right here.

Still waiting… you are taking your time I see!

Good… that wasn’t too bad, was it? Now, when you log into your new VM, as long as you have a DHCP server and a router configured, you should already be connected to the Internet!


So… what can you do on this virtual machine? Just about anything you can do on a physical machine. You can also, if you so desire, build more virtual machines, and either connect them all through your existing infrastructure… or you can configure either an Internal or Private virtual switch to connect them to each other. Let me explain:

In 2012 I wrote an article called Getting Started with Hyper-V in Server 2012 and Windows 8. This was the first version of the client OS that had Hyper-V, and it was really in Windows Server 2012 that Hyper-V really became a competitive alternative to the long-established market leader, VMware vSphere. In the article I wrote about the three different types of virtual switches you could create, with the three decisions you had to make regarding Hyper-V networking:

  • Is the network going to be External (can communicate beyond the physical host), Internal (can only communicate with other VMs on the same host, plus with the host), or Private (can only communicate with other VMs on the same host)?
  • If External, what physical NIC (uplink) will it be bound to?
  • Can the Management OS (on the host) use the same NIC?

This is as true today as it was then; although there have certainly been some tremendous advancements, the three types of virtual switch have not changed.

If your virtual switch is External, then you have connectivity to the outside world… at least, you have connectivity to a network interface card, which might be connected to something. In the case of my environment, I have shown that my VM is directly connected to the Internet through my WiFi router. If your virtual switch is either Internal or Private, the virtual machines connected to it will not be connected to the outside world; in fact, they will not even be connected properly to each other until you assign them IP addresses.


Now that you have learned to create a virtual machine, you can now create more of them. In the cmdlets you just have to change the name of the VM and VHDX file. There is more that you can do with Hyper-V in Windows 10, but for now I am going to leave it here.

Tomorrow we will get back to articles about Windows 10, Microsoft 365, Microsoft Endpoint Management, AzureAD, and so much more cloud goodness. However, for the last few days it was nostalgic to be writing about Hyper-V… and I hope it will help you to further your IT career with lab machines you can break as needed!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: