How to Set Up Windows Server 2016 Hyper-V

Hyper-V is Microsoft’s native hypervisor, built into Windows Server 2016. It allows you to create and manage virtual machines (VMs), enabling server consolidation, test environments, and high availability scenarios. Windows Server 2016 Hyper-V includes enhancements such as Shielded VMs, Host Guardian Service, nested virtualization, and improved Linux guest support.

Prerequisites

  • A 64-bit processor with hardware virtualization support (Intel VT-x or AMD-V).
  • Hardware Data Execution Prevention (DEP) enabled in BIOS/UEFI.
  • Minimum 4 GB RAM (8 GB or more recommended for production).
  • Sufficient disk space for VM storage.

Verify hardware virtualization is supported:

systeminfo | findstr /i "Virtualization"

Step 1: Install the Hyper-V Role

Install Hyper-V using PowerShell:

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart

The -Restart flag automatically reboots the server after installation. After restart, verify Hyper-V is installed:

Get-WindowsFeature -Name Hyper-V

Step 2: Configure Hyper-V Host Settings

Set the default virtual machine and virtual hard disk storage paths:

Set-VMHost -VirtualMachinePath "D:VMs" -VirtualHardDiskPath "D:VMsVHDs"

View current host settings:

Get-VMHost | Select-Object VirtualMachinePath, VirtualHardDiskPath, NumaSpanningEnabled, MaximumStorageMigrations

Step 3: Create a Virtual Switch

Virtual switches connect VMs to physical or internal networks. Create an external virtual switch bound to a physical adapter:

New-VMSwitch -Name "ExternalSwitch" -NetAdapterName "Ethernet" -AllowManagementOS $true

List all virtual switches:

Get-VMSwitch

Step 4: Create a New Virtual Machine

Create a Generation 2 VM (UEFI-based, recommended for modern operating systems):

New-VM -Name "VM01" `
  -Generation 2 `
  -MemoryStartupBytes 2GB `
  -NewVHDPath "D:VMsVHDsVM01.vhdx" `
  -NewVHDSizeBytes 60GB `
  -SwitchName "ExternalSwitch" `
  -Path "D:VMs"

Step 5: Configure VM Settings

Assign a DVD drive with an ISO for OS installation:

Add-VMDvdDrive -VMName "VM01" -Path "C:ISOsWindows2016.iso"

Set the boot order to boot from DVD first:

$dvd = Get-VMDvdDrive -VMName "VM01"
Set-VMFirmware -VMName "VM01" -FirstBootDevice $dvd

Enable Dynamic Memory:

Set-VMMemory -VMName "VM01" -DynamicMemoryEnabled $true -MinimumBytes 512MB -MaximumBytes 4GB -StartupBytes 2GB

Set virtual CPU count:

Set-VMProcessor -VMName "VM01" -Count 4

Step 6: Start the Virtual Machine

Start-VM -Name "VM01"

Connect to the VM console using VMConnect:

vmconnect.exe localhost "VM01"

Step 7: Install Hyper-V Integration Services

For Windows guests, Integration Services are included with Hyper-V. For Linux guests, install the linux-hyperv package. Verify integration services status from the host:

Get-VMIntegrationService -VMName "VM01"

Enable all integration services:

Enable-VMIntegrationService -VMName "VM01" -Name "Guest Service Interface","Heartbeat","Key-Value Pair Exchange","Shutdown","Time Synchronization","VSS"

Step 8: Create VM Checkpoints

Checkpoints capture the VM state and can be used for rollback:

Checkpoint-VM -Name "VM01" -SnapshotName "BeforeUpdate"

List checkpoints:

Get-VMCheckpoint -VMName "VM01"

Restore a checkpoint:

Restore-VMCheckpoint -Name "BeforeUpdate" -VMName "VM01" -Confirm:$false

Step 9: Enable Nested Virtualization

Windows Server 2016 supports nested virtualization, allowing Hyper-V to run inside a VM. Enable it while the VM is stopped:

Set-VMProcessor -VMName "VM01" -ExposeVirtualizationExtensions $true

Step 10: List All VMs and Status

Get-VM | Select-Object Name, State, CPUUsage, MemoryAssigned, Uptime
Get-VMHardDiskDrive -VMName "VM01"
Get-VMNetworkAdapter -VMName "VM01"

To view all VMs on a remote Hyper-V host:

Get-VM -ComputerName "HyperV-Host2" | Select-Object Name, State

Troubleshooting Hyper-V

If Hyper-V fails to start, verify that hardware virtualization is enabled in BIOS and that the feature is installed correctly:

Get-WinEvent -LogName "Microsoft-Windows-Hyper-V-Worker-Admin" -MaxEvents 20 | Select-Object TimeCreated, Message
Get-WinEvent -LogName "Microsoft-Windows-Hyper-V-VMMS-Admin" -MaxEvents 20 | Select-Object TimeCreated, Message

Summary

Setting up Hyper-V on Windows Server 2016 is straightforward using PowerShell or Server Manager. Once the role is installed, you can create and manage VMs with flexible resource allocation, virtual switches, and checkpoints. Hyper-V provides a cost-effective virtualization platform tightly integrated with Windows management tools and Active Directory.