Hyper-V is Microsoft's built-in type 1 hypervisor. This guide shows how to enable Hyper-V on Windows Server 2019, 2022 or 2025, set up networking and create your first virtual machine, using either the GUI or PowerShell.
Before you start
- A physical server or dedicated machine with Windows Server and administrator rights. A normal Windows VPS cannot run Hyper-V unless nested virtualization is enabled by the provider; see nested virtualization.
- VT-x or AMD-V, plus SLAT (EPT/NPT), enabled in firmware.
- Remote console access, because the network briefly drops when creating an external switch.
Install the Hyper-V role
With PowerShell (run as administrator):
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -RestartWith Server Manager: Manage → Add Roles and Features → Role-based installation, tick Hyper-V, accept the management tools, and choose whether to create a virtual switch now. Restart when asked.
Create a virtual switch
Hyper-V has three switch types: External (bridged to a physical NIC), Internal (host and VMs only) and Private (VMs only). For VMs with network access:
Get-NetAdapterNew-VMSwitch -Name "External" -NetAdapterName "Ethernet" -AllowManagementOS $trueIn the GUI: Hyper-V Manager → Virtual Switch Manager → New virtual network switch → External.
Create a virtual machine
New-VM -Name "web01" -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath "D:\VMs\web01.vhdx" -NewVHDSizeBytes 60GB -SwitchName "External"Set-VMProcessor -VMName "web01" -Count 2Add-VMDvdDrive -VMName "web01" -Path "D:\ISO\ubuntu-24.04-live-server-amd64.iso"For Linux on Generation 2, change Secure Boot to the Microsoft UEFI CA template (or disable it):
Set-VMFirmware -VMName "web01" -SecureBootTemplate "MicrosoftUEFICertificateAuthority" -FirstBootDevice (Get-VMDvdDrive -VMName "web01")Start it and connect from Hyper-V Manager with Connect:
Start-VM -Name "web01"After installation
- Linux guests include Hyper-V integration drivers; install
linux-cloud-toolsorhyperv-daemonsfor extra services. - Set automatic start:
Set-VM -Name web01 -AutomaticStartAction Start. - Use checkpoints before risky changes, but keep real backups.
Troubleshooting
- "Hyper-V cannot be installed: the processor does not have required virtualization capabilities": enable VT-x/AMD-V in firmware, or ask your VPS provider about nested virtualization.
- VM will not boot Linux ISO: wrong Secure Boot template on Generation 2.
- Host lost network after creating switch: the host now uses the vEthernet adapter; reapply its static IP there.
Frequently asked questions
Generation 1 or 2?
Use Generation 2 for modern OSes: UEFI, Secure Boot and faster boot. Generation 1 is for legacy BIOS-only systems.
Can I manage Hyper-V remotely?
Yes, with Hyper-V Manager or Windows Admin Center from another machine, or PowerShell remoting.
How do I open the host firewall for RDP?
See Windows Defender Firewall rules with PowerShell.
