How to Set Up Hyper-V on Windows Server 2012 R2
Hyper-V is Microsoft’s Type-1 hypervisor, shipping as a role in Windows Server 2012 R2. It enables hardware virtualisation directly on the server, allowing you to run multiple virtual machines (VMs) with different operating systems on the same physical hardware. Windows Server 2012 R2 Hyper-V includes major features: Generation 2 VMs with UEFI Secure Boot, shared virtual hard disks for guest clustering, enhanced session mode for improved RDP to VMs, online VHDX resizing, and VM replication via Hyper-V Replica.
This guide covers installing the Hyper-V role, understanding key concepts, configuring Hyper-V settings, planning storage, and preparing the host for production VM workloads.
Prerequisites
- 64-bit processor with hardware virtualisation support (Intel VT-x or AMD-V) enabled in BIOS/UEFI.
- SLAT (Second Level Address Translation — Intel EPT or AMD RVI) support — required for Hyper-V on Server 2012 R2.
- Hardware Data Execution Prevention (DEP) enabled (Intel XD, AMD NX bit).
- Minimum 4 GB RAM on the host (much more recommended for production).
- Windows Server 2012 R2 Standard or Datacenter edition.
Step 1: Verify Hardware Support
# Check if the CPU supports virtualisation and SLAT
Get-WmiObject -Class Win32_Processor |
Select-Object Name, NumberOfCores, AddressWidth, VirtualizationFirmwareEnabled
# Use systeminfo to check Hyper-V requirements
systeminfo | findstr /i "Hyper-V"
# Expected output shows:
# Hyper-V Requirements: VM Monitor Mode Extensions: Yes
# Virtualization Enabled In Firmware: Yes
# Second Level Address Translation: Yes
# Data Execution Prevention Available: Yes
# If Hyper-V is already installed, it will show "A hypervisor has been detected"
Step 2: Install the Hyper-V Role
# Install Hyper-V role with management tools
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
# NOTE: The -Restart switch will reboot the server immediately after installation
# If you want to control the reboot, omit -Restart and reboot manually
# After reboot, verify the installation
Get-WindowsFeature -Name Hyper-V | Select-Object Name, InstallState
# Verify Hyper-V services are running
Get-Service -Name vmms, vmcompute, vhdsvc |
Select-Object Name, DisplayName, Status
# Check Hyper-V version
Get-ItemProperty "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionVirtualization" |
Select-Object Version
Step 3: Configure Hyper-V Host Settings
Before creating VMs, configure the Hyper-V host’s default settings: where to store VMs and VHDs, whether to allow live migrations, and enhanced session mode.
# Import Hyper-V module
Import-Module Hyper-V
# Set default VM and VHD storage paths (use dedicated data volumes, not C:)
Set-VMHost `
-ComputerName localhost `
-VirtualMachinePath "D:Hyper-VVMs" `
-VirtualHardDiskPath "D:Hyper-VVHDs"
# Enable enhanced session mode (better RDP resolution, clipboard, drive redirection in Hyper-V Manager)
Set-VMHost -EnhancedSessionModePolicy Allowed -ComputerName localhost
# Configure the maximum number of concurrent live migrations
Set-VMHost -MaximumVirtualMachineMigrations 2 -ComputerName localhost
# Set the number of NUMA nodes to expose (advanced)
# Set-VMHost -NumaSpanningEnabled $true
# View all host settings
Get-VMHost | Select-Object `
VirtualMachinePath, `
VirtualHardDiskPath, `
EnableEnhancedSessionMode, `
MaximumVirtualMachineMigrations, `
NumaSpanningEnabled
Step 4: Configure Storage for Hyper-V
Hyper-V storage performance is critical. Plan your storage layout before deploying VMs — keeping OS, page file, and VM storage on separate volumes significantly improves performance and simplifies backup.
# Recommended partition layout example:
# C: - Windows Server OS (100 GB minimum)
# D: - VM storage (size based on expected VM workloads)
# E: - VM checkpoints / snapshots (if enabled)
# Create directory structure on the VM data volume
New-Item -Path "D:Hyper-VVMs" -ItemType Directory
New-Item -Path "D:Hyper-VVHDs" -ItemType Directory
New-Item -Path "D:Hyper-VISO" -ItemType Directory
# For iSCSI-attached storage, connect the iSCSI initiator first
# Start the Microsoft iSCSI Initiator Service
Start-Service -Name MSiSCSI
Set-Service -Name MSiSCSI -StartupType Automatic
# Connect to iSCSI target
New-IscsiTargetPortal -TargetPortalAddress "192.168.100.10"
Connect-IscsiTarget -NodeAddress "iqn.2024-01.com.example:storage01"
# Verify disk is online
Get-Disk | Where-Object { $_.OperationalStatus -eq "Online" }
Step 5: Configure Hyper-V Networking
Hyper-V networking requires creating virtual switches before VMs can connect to the network. Virtual switches bridge VM network traffic to physical NICs or keep traffic isolated internally.
# List physical network adapters available
Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, LinkSpeed
# Create an external virtual switch (VMs share the physical NIC with the host)
New-VMSwitch `
-Name "External-vSwitch" `
-NetAdapterName "Ethernet 2" `
-AllowManagementOS $true
# Create an internal virtual switch (VMs can talk to the host but not the physical network)
New-VMSwitch -Name "Internal-vSwitch" -SwitchType Internal
# Create a private virtual switch (VMs can only talk to each other)
New-VMSwitch -Name "Private-vSwitch" -SwitchType Private
# List all virtual switches
Get-VMSwitch | Select-Object Name, SwitchType, NetAdapterInterfaceDescription
Step 6: Configure Hyper-V Replica for Disaster Recovery
Hyper-V Replica asynchronously replicates VMs to a secondary Hyper-V host, providing disaster recovery without shared storage.
# Enable the Hyper-V Replica on the primary host
Set-VMReplicationServer `
-ReplicationEnabled $true `
-AllowedAuthenticationType Kerberos `
-ReplicationAllowedFromAnyServer $false `
-DefaultStorageLocation "D:Hyper-VReplica"
# Allow replication from a specific server
New-VMReplicationAuthorizationEntry `
-AllowedPrimaryServer "HYPERV01.corp.example.com" `
-ReplicaStorageLocation "D:Hyper-VReplica" `
-TrustGroup "CorpReplica"
# Add Windows Firewall rule for Hyper-V Replica (Kerberos, port 80)
Enable-NetFirewallRule -DisplayName "Hyper-V Replica HTTP Listener (TCP-In)"
# Verify replica server configuration
Get-VMReplicationServer
Step 7: Post-Installation Verification
# Confirm Hyper-V is fully operational
Get-VMHost | Select-Object Name, VirtualMachinePath, VirtualHardDiskPath
# List all VMs (will be empty on a new host)
Get-VM
# Check Hyper-V event log for errors
Get-EventLog -LogName "Microsoft-Windows-Hyper-V-VMMS-Admin" -EntryType Error -Newest 10
# Confirm virtual switch is working
Get-VMSwitch
Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "*Hyper-V*" }
# Check host available RAM
(Get-VMHost).TotalMemoryUsage
Get-VM | Measure-Object -Property MemoryAssigned -Sum | Select-Object Sum
# Monitor Hyper-V performance counters
Get-Counter -Counter "Hyper-V Hypervisor Logical Processor(_Total)% Total Run Time" -SampleInterval 2 -MaxSamples 5
Summary
Installing and configuring Hyper-V on Windows Server 2012 R2 is a straightforward process once hardware prerequisites are confirmed. The key preparation steps are: verify CPU virtualisation and SLAT support, install the Hyper-V role with a controlled reboot, configure default VM and VHD paths on dedicated data volumes (never C:), create external virtual switches for VM network access, and enable Hyper-V Replica for disaster recovery coverage. For production deployments, allocate enough physical RAM for your expected VM workloads plus at least 2–4 GB reserved for the host OS, and always store VMs on storage separate from the host operating system volume to ensure backup and performance isolation.