How to Create a Windows Virtual Machine on Hyper-V Server

How to Create a Windows Virtual Machine on Hyper-V Server. Virtualization technologies like Hyper-V from Microsoft help you virtualize operating systems and hardware. As a result, you save costs and increase IT agility, scalability, and flexibility.

Microsoft has three versions of Hyper-V:

In this article, we’ll focus on Hyper-V Server and go over the step by step process of setting up a virtual machine.

Shall we start with How to Create a Windows Virtual Machine on Hyper-V Server?

What is Hyper-V Server?

First of all, Hyper-V Server is a free VM management platform by Microsoft that works with the company’s confusingly named hypervisorHyper V. Well, it is worth noting that these are different products. 

Above all, Hyper-V Server is a special operating system that has Windows Server Core installed and the Hyper-V role preconfigured. Whilst the operating system is available for free, you still need to pay license fees for your Windows VMs. Fortunately, Hyper-V Server allows you to run Linux VMs. 

In essence, Hyper-V Server is a lightweight version of Windows Server, that’s optimized to act solely as a Hyper-V host. According to Microsoft, Hyper-V Server provides enterprise class virtualization for the hybrid cloud and data centers. Additionally, the tool comes with a rich set of features that allow you to deliver and scale the performance of mission critical workloads.

Hyper-V Server Pros

  • Supports multiple operating systems, including Windows, FreeBSD, and Linux. 
  • Multiple ways to back up VMs.
  • Hyper-V Server doesn’t come with a GUI.
  • But it allows for remote management using standard Hyper-V Manager. Above all, it also comes with web access via the Windows Admin Centre. 
  • Easy to use if you’re familiar with Hyper-V. 
  • No need for a license for the hypervisor
  • Relatively low hardware requirements due to reduced resource demands. 
  • Reduced patching burden due to the fewer components enabled in the system. 
  • The lack of a GUI discourages tinkering and bad behaviour from admins. 
  • With fewer active components compared to Hyper-V, there’s a reduced attack surface from hackers. 

Hyper-V Server Cons

  • No GUI, so you’re locked into the command-line mode. 
  • Does not support local disk duplication. 

Create a Windows Virtual Machine on Hyper-V Server Using PowerShell

Basically, Hyper-V Server doesn’t come with a graphical user interface. As a result, PowerShell is one of the easiest ways to create and manage a Hyper-V VM. Here’s how to go about it:

Step 1: On Hyper-V server, open the command line by typing 14  into the Sconfig window. This is the Exit to Command Line command in Hyper-V Server 2019.

Step 2: Type PowerShell in the command Prompt and hit Enter to start a Windows PowerShell session.

Step 3: Run the New VM cmdlet as shown below:

				
					New-VM -Name "MyNewVM" -MemoryStartupBytes 4GB -Path "E:\VM\MyNewVM" -NewVHDPath "E:\VM\MyNewVM\MyNewVM.vhdx" -NewVHDSizeBytes 60GB -Generation 2 -SwitchName "MyNetwork"

				
			

New VM

Running this command creates a new Generation 2 VM called MyNewVM. Here’s a description of the parameters we’ve used:

  • New-VM – a cmdlet that creates a new virtual machine. 
  • Name – the name of the VM you’re creating. 
  • MemoryStartupBytes – the amount of memory assigned to the VM during startup. 
  • Path – a directory path of your virtual machine. 
  • NewVHDPath – specifies the location of your VM’s virtual disk. If you want to connect to an existing VHD, use the -VHDPath parameter instead. You can create a new VM without a VHD using -NoVHD. 
  • NewVHDSizeBytes – this is the size of the VHD. 
  • Generation – generation of the VM. You can choose between a Generation 1 and Generation 2 VM.

Up next with How to Create a Windows Virtual Machine on Hyper-V Server but remotely.

How to Create Windows Virtual Machine Remotely

Besides using PowerShell, you can also create VMs on Hyper-V Server from the graphic interface using Windows Admin Centre and Hyper-V Manager. Steps to follow are below:

Configure Hyper-V Server (Host) for Remote Access

First, before you can create a VM remotely, you need to configure your VM server for remote access. Let’s break it down below:

  • Step 1: Start Hyper-V Server and open command prompt by typing 14 into the Scofig window. 
				
					Start powershell
				
			
  • Step 3: Check if WinRM is enabled on your server using the following command: 
				
					WinRM quickconfig
				
			

If WinRM is not enabled, you’ll see the following:

Enter “y” to proceed. 

  • Step 4: Next, enable Hyper-V Server to receive PowerShell remote commands using the following command:
				
					Enable-PSRemoting
				
			
  • Step 5: Enter the following command to allow Hyper-V Server to receive credentials from the Shift server. 
				
					Enable-WSManCredSSP -role server
				
			

As a result, Hyper-V Server is now ready for remote access.

Accessing Hyper-V on a Local Computer (Client)

Concurrently, to connect and manage Hyper-Server remotely access, you’ll need a PC running a Windows 10/11 Pro/Enterprise (64-bit). After all, I will show you how to access Hyper-V Server from your local PC. 

  • Press Win+R to open Run.
  • Type “Control” into the textbox and hit Enter to open the Control Panel. 
  • Go to Programs and then navigate to Programs and Features
  • Navigate to the left pane and click on the Turn Windows features on or off option. 
  • Next, select Hyper-V in the Windows Features dialog. Make sure to select both Hyper-V platforms and Hyper-V Management in the expanded menu. 

Click OK. The computer will restart after you enable Hyper-V. 

Open PowerShell

  • Step 2: Open PowerShell in administrator mode. 
  • Step 3: Check your network profile by entering the following command and hitting enter. 
				
					Get-NetConnectionProfile
				
			
  • Step 4:  If your network category is set to private, change it to public using the following command. 
				
					Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private
				
			

Hit Enter. You have now changed the public network to private network successfully.

Step 5: Update Windows host file and update and append the IP and computer name of the Hyper-V server using the following command.

				
					Add-Content .-Path "directory path" -Value "`nLOCALSERVERIP`tSERVER-NAME"
				
			

Make sure to append “n” before the local server IP and “t” before the server name.

  • Step 6: To configure the local computer to manage the Hyper-V server remotely, enter the command shown below. 
				
					Set-WSManQuickConfig -SkipNetworkProfileCheck
				
			

Press Type “Y” to confirm. You should see a success message in a few seconds. 

  • Step 7: Next, add the Hyper-V Server to trusted host with the following command. 
				
					Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "HYPER-V SERVER-NAME"
				
			

Please Type “Y” to confirm. 

Now, you can check whether your server has been added to the trusted host with this command:

				
					Set-Item -Path WSMan:\localhost\Client\TrustedHosts
				
			
  • Step 8: Enable CredSSP authentication to the local computer. Add the delegate computer as your Hyper-V Server. 
				
					Enable-WSManCredSSP -Role Client -DelegateComputer "HYPER-V SERVER-NAME" 
				
			

Then Type “Y” to confirm. 

In order to confirm that the changes have been effected enter the following command:

				
					Enable-WSManCredSSP
				
			
  • Step 9: Create Hyper-V server credentials with this command:
				
					cmdkey /add:hyper-v /user:Administrator /pass:SERVERADMINPASSWORD
				
			

These credentials will be passed to the remote Hyper-V server for authentication. 

Use Hyper-V Manager to Create a Windows Virtual Machine on Hyper-V Server

Consequently, Hyper-V Manager is a VM management tool that allows users to create, manage, and delete VMs. Equally, here’s how to use Hyper-V Manager to create VMs remotely. 

  • Step 1: Open Hyper-V Manager by typing Hyper-V Manager into the Windows search box.
  • Step 2: On the left menu, right-click on Hyper-V server and select Connect to Server on the left menu.
  • Step 3: In the new window, enter the server name in the Another Computer field. Click OK to proceed. You’re now connected to the Hyper-V server remotely. 
  • Step 4: Click Action and select New > Virtual Machine to launch the New Virtual Machine wizard.
  • Step 5: Click Next to navigate to the Specify Name and Location window. Enter the name of the virtual machine and select where to save it. Click Next
  • Step 6: On the Specify Generations page, choose between Generation 1 and Generation 2 VMs. Especially, read through the descriptions provided on the page so you can choose the right generation. Recommendation from us is Generation. After that, click Next. 
  • Step 7: On the Assign Memory page, select the amount of memory to assign to the VM. The  Use dynamic memory for this virtual machine option allows memory to be allocated to Hyper-V VMs dynamically. Leave this option checked if you’re running several VMs.  Then Click Next
  • Step 8: On the Configure Networking page, leave the default selection and click Next
  • Step 9: On the Create Virtual Hard Disk page select a location and size of the virtual hard disk and click Next
  • Step 10: Under Installation Options, select  Install an operating system from a bootable image file. Following on that, choose a Windows 10/11 .iso file  and click Later, create a Windows virtual machine on Hyper-V Server. Once done Click Next
  • Step 11: Review the information and click Finish.

Use Windows Admin Center to Create a Windows Virtual Machine on Hyper-V Server

Well, Windows Admin Center is a locally-deployed, browser based tool that allows you to manage Windows Servers. In addition, it gives you control over every aspect of your server infrastructure and is particularly useful if you have virtual servers running on a private network. 

Particularly, with Windows Admin Center is available for free and is free to use in production. So, here’s how to use it to create a Windows VM:

  • Step 2: Open Windows Admin Center. It should open on your default browser
  • Step 3: Click Add and proceed to click Add under the Server menu item. 
  • Step 4: Enter your Hyper-V Server name to connect. Now you can manage your Hyper-V server remotely from Windows Admin Center. 
  • Step 5: Go to the Windows Admin Center home screen, go to All Connections and select the server you just added.
  • Step 6: Under tools, select Virtual Machines. Here, select the inventory tab and then Add > New.
  • Step 7: Give a name to your new virtual machine and Select Generation 2. 
  • Step 8:  Under Host, the tool will provide a host recommendation for you.
  • Step 9: Choose a path for storing the VM files.
  • Step 10: Choose the number of virtual processors and whether you want to enable nested virtualization. You’ll also configure network adapters, memory settings, and virtual hard disks. 
  • Step 11: To install an OS, select an .iso image file. Select Create to finish creating the VM. The new VM should appear in the list of virtual machines on the Windows Admin Center home page. 

Thank you for reading How to Create a Windows Virtual Machine on Hyper-V Server. We shall conclude.

How to Create a Windows Virtual Machine on Hyper-V Server Conclusion

To summarize, Hyper-V Server is the perfect operating system for running Linux VMs and VDI (virtual desktop infrastructure) workloads. Also, it’s a great tool for learning and running a home lab environment since it’s available for free. 

However, Hyper-V Server does have its limitations in terms of features, roles, and licenses. It’s purpose built for running virtualized workloads and nothing else, so you shouldn’t expect to install other features and roles once Hyper-V Server is up and running. Also, Hyper-V Server 2019 is the end of the road for free Hyper-V Server installations. Even then, support from Microsoft will be available until 2029.  

Please check out more Hyper-V content in our blog. 

Avatar for Richard Kanyoro
Richard Kanyoro

The world’s biggest problems can be solved by progressively solving the little ones. I write to help people solve the “little” tech problems they face.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x