Install Hyper-V
This article shows how to install Hyper-V in Windows and Windows Server. Follow the set of instructions that fit your
needs.
Enable Hyper-V to create virtual machines on Windows. Hyper-V can be enabled in many ways including using
the Windows control panel, PowerShell, or using the Deployment Imaging Servicing and Management tool
(DISM). This article walks through each option.
NoteHyper-V is built into Windows as an optional feature--there's no Hyper-V download.
Check requirements for Windows
Windows 10 (Pro or Enterprise), or Windows 11 (Pro or Enterprise)
64-bit Processor with Second Level Address Translation (SLAT).
CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs).
Minimum of 4-GB memory.
NoteThe Hyper-V role can't be installed on Windows 10 Home or Windows 11 Home.
For more information and troubleshooting, see Windows Hyper-V System Requirements.
Enable Hyper-V
PowerShell
To enable Hyper-V on Windows using PowerShell:
1. On the Windows desktop, select the Start button and type any part of the name Windows PowerShell.
2. Right-click Windows PowerShell and select Run as Administrator.
Important
You must run PowerShell as an Administrator, or the commands fail.
3. Run the following command:
PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
4. Enter Y to have the computer restart to complete the installation.
To enable the Hyper-V role on Windows using DISM:
The Deployment Image Servicing and Management tool (DISM) helps configure Windows and Windows images. Among
its many applications, DISM can enable Windows features while the operating system is running.
1. On the Windows desktop, select the Start button and type any part of the name Windows PowerShell.
2. Right-click Windows PowerShell and select Run as Administrator.
3. Type the following command:
PowerShell
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
4. You see that the feature is enabled and that "The operation completed successfully."
For more information about DISM, see the DISM Technical Reference.
Enable Hyper-V
PowerShell
GUI
To enable Hyper-V on Windows 11:
1. Navigate to the Control Panel. Select Start, then search for Control Panel to open the application.
2. Select Programs, then Programs and Features.
3. Select Turn Windows Features on or off.
4. Select Hyper-V and then select OK.
When the installation completes, you're prompted to restart your computer.
To enable Hyper-V on Windows 10:
1. Select Start, then search for and select Settings.
2. Select Apps & features. Then select Programs and Features
3. Select Turn Windows features on or off.
4. Select Hyper-V and then select OK.
5. To complete the installation, restart your computer.
Create a virtual machine in
Hyper-V
Learn how to create a virtual machine by using Hyper-V Manager and Windows PowerShell and what options you have
when you create a virtual machine in Hyper-V Manager.
Prerequisites
Before you create a virtual machine, make sure you have the following prerequisites:
A computer running Windows Server or Windows client with Hyper-V enabled. For more information,
see Install the Hyper-V role on Windows Server.
Membership in the local Administrators group or the Hyper-V Administrators group.
Sufficient physical memory on the host to allocate to the virtual machine.
Sufficient disk space for virtual machine configuration files and virtual hard disks.
(Optional) A virtual switch configured if you want network connectivity for the virtual machine. See Create a
virtual switch for Hyper-V virtual machines.
(Optional) An operating system installation media (.iso file) or an existing virtual hard disk (.vhd or .vhdx) if
you want to install an operating system.
Create a virtual machine
To create a virtual machine, use either Hyper-V Manager or Windows PowerShell. Select the method you prefer:
Hyper-V Manager
To create a virtual machine in Hyper-V Manager, follow these steps:
1. Select the Start button, type Hyper-V Manager, and then select it from the list.
NoteIf you don't see Hyper-V Manager, make sure that the Hyper-V role is installed. For more information, see Install
the Hyper-V role on Windows Server.
2. In the left pane, under Hyper-V Manager, select your server.
3. From the Actions pane, select New, then select Virtual Machine.
4. From the New Virtual Machine Wizard, select Next.
5. For the Specify Name and Location page, enter a name for the virtual machine and choose a location to
store the virtual machine configuration files. Select Next.
(Optionally) If you want to store the virtual machine configuration files in a different location, select the Store the
virtual machine in a different location check box and then browse to the folder where you want to store the files.
6. In the Specify Generation page, select the generation of the virtual machine. For more information,
see Should I create a generation 1 or 2 virtual machine in Hyper-V?. Create a generation 2 virtual machine unless you
have a specific reason to create a generation 1 virtual machine. Select Next.
7. For the Assign Memory page, enter the amount of memory to allocate to the virtual machine at startup. You
can also choose to enable Dynamic Memory. For more information, see Hyper-V Dynamic Memory Overview.
Select Next.
NoteThe minimum amount of memory you can assign is 32 MB and the maximum is 5,902 MB.
8. For the Configure Networking page, select a virtual switch to connect the virtual machine to the network. If
you don't have a virtual switch created, you can skip this step and configure networking later. Select Next.
9. In the Connect Virtual Hard Disk page, choose one of the following options, then select Next:
o Create a virtual hard disk - Enter a name for the virtual hard disk, choose a location to store it,
and specify its size.
o Use an existing virtual hard disk - Browse to the location of an existing virtual hard disk
(.vhd or .vhdx).
o Attach a virtual hard disk later - You can attach a virtual hard disk later.
10. For the Installation Options page, choose how you want to install the operating system on the virtual
machine. You can choose one of the following options, then select Next:
o Install an operating system later
o Install an operating system from a bootable image file - Browse to the location of an .iso file
that contains the operating system installation media.
o Install an operating system from a bootable floppy disk - Select a floppy disk drive that
contains the operating system installation media.
o Install an operating system from a network-based installation server - This option is for
using Windows Deployment Services (WDS) or another network-based installation service.
11. After verifying your choices in the Summary page, select Finish.
Start and connect to the virtual machine
After you create the virtual machine, you can start it and connect to it. You can use either Hyper-V Manager or
Windows PowerShell. Select the method you prefer:
Hyper-V Manager
To start and connect to the virtual machine in Hyper-V Manager, follow these steps:
1. In Hyper-V Manager, right-click the virtual machine and select Connect....
2. In the Virtual Machine Connection window, select Action > Start.
Create a virtual machine
To create a virtual machine, use either Hyper-V Manager or Windows PowerShell. Select the method you prefer:
PowerShell
To create a virtual machine with Windows PowerShell using New-VM, follow these steps:
1. On the Windows desktop, select the Start button and type Windows PowerShell.
2. Right-click on Windows PowerShell and select Run as administrator.
3. Use the Get-VMSwitch cmdlet to get the name of the virtual switch that you want the virtual machine to use:
PowerShell
Get-VMSwitch * | Format-Table Name
4. Use the New-VM cmdlet to create the virtual machine. See the following examples:
Note
Use the -Version parameter if you need to move this virtual machine to a host running an older Windows Server
version. See Supported virtual machine configuration versions.
o Existing virtual hard disk - To create a virtual machine with an existing virtual hard disk, use the
following command where,
o -Name is the name that you provide for the virtual machine that you're creating.
o -MemoryStartupBytes is the amount of memory that's available to the virtual machine
at startup.
o -BootDevice is the device that the virtual machine boots to when it starts, like the
network adapter (NetworkAdapter) or virtual hard disk (VHD).
o -VHDPath is the path to the virtual machine disk that you want to use.
o -Path is the path to store the virtual machine configuration files.
o -Generation is the virtual machine generation. Use generation 1 for VHD and generation
2 for VHDX. See Should I create a generation 1 or 2 virtual machine in Hyper-V?.
o -Switch is the name of the virtual switch that you want the virtual machine to use to
connect to other virtual machines or the network. See Create a virtual switch for Hyper-V virtual machines.
PowerShell
New-VM -Name <Name> -MemoryStartupBytes <Memory> -BootDevice <BootDevice> -
VHDPath <VHDPath> -Path <Path> -Generation <Generation> -Switch
<SwitchName>
For example:
PowerShell
New-VM -Name TestVM -MemoryStartupBytes 4GB -BootDevice VHD -VHDPath .\VMs\
[Link] -Path .\VMData -Generation 2 -Switch ExternalSwitch
This example creates a generation 2 virtual machine named TestVM with 4 GB of memory. It boots from the folder
VMs\[Link] in the current directory and uses the virtual switch named ExternalSwitch. The virtual machine
configuration files are stored in the folder VMData.
o New virtual hard disk - To create a virtual machine with a new virtual hard disk, replace the -
VHDPath parameter from the previous example with -NewVHDPath and add the -NewVHDSizeBytes parameter.
For example,
PowerShell
New-VM -Name TestVM -MemoryStartupBytes 4GB -BootDevice VHD -NewVHDPath .\
VMs\[Link] -Path .\VMData -NewVHDSizeBytes 20GB -Generation 2 -Switch
ExternalSwitch
o New virtual hard disk that boots to operating system image - To create a virtual machine
with a new virtual disk that boots to an operating system image, see the PowerShell example in Create virtual machine
walkthrough for Hyper-V on Windows.
Start and connect to the virtual machine
After you create the virtual machine, you can start it and connect to it. You can use either Hyper-V Manager or
Windows PowerShell. Select the method you prefer:
PowerShell
To start and connect to the virtual machine using Windows PowerShell, follow these steps:
1. Start the virtual machine by using the Start-VM cmdlet. Run the following cmdlet where Name is the name of
the virtual machine you created:
PowerShell
Start-VM -Name <Name>
For example:
PowerShell
Start-VM -Name TestVM
2. Connect to the virtual machine by using Virtual Machine Connection (VMConnect):
PowerShell
[Link] <ServerName> <VMName>
For example:
PowerShell
[Link] localhost "TestVM"