How to create a virtual machine in Hyper-V

From Microsoft Website:

Create a virtual machine by using Hyper-V Manager

  1. Open Hyper-V Manager.
  2. From the Action pane, click New, and then click Virtual Machine.
  3. From the New Virtual Machine Wizard, click Next.
  4. Make the appropriate choices for your virtual machine on each of the pages. For more information, see New virtual machine options and defaults in Hyper-V Manager later in this topic.
  5. After verifying your choices in the Summary page, click Finish.
  6. In Hyper-V Manager, right-click the virtual machine and select connect.
  7. In the Virtual Machine Connection window, select Action > Start.

Create a virtual machine by using Windows PowerShell

  1. On the Windows desktop, click the Start button and type any part of the name Windows PowerShell.
  2. Right-click Windows PowerShell and select Run as administrator.
  3. Get the name of the virtual switch that you want the virtual machine to use by using Get-VMSwitch. For example, Get-VMSwitch * | Format-Table Name
  4. Use the New-VM cmdlet to create the virtual machine. See the following examples.

     Note

    If you may move this virtual machine to a Hyper-V host that runs Windows Server 2012 R2, use the -Version parameter with New-VM to set the virtual machine configuration version to 5. The default virtual machine configuration version for Windows Server 2016 isn’t supported by Windows Server 2012 R2 or earlier versions. You can’t change the virtual machine configuration version after the virtual machine is created. For more information, see Supported virtual machine configuration versions.

    • Existing virtual hard disk – To create a virtual machine with an existing virtual hard disk, you can use the following command where,
      • -Name is the name that you provide for the virtual machine that you’re creating.
      • -MemoryStartupBytes is the amount of memory that is available to the virtual machine at start up.
      • -BootDevice is the device that the virtual machine boots to when it starts like the network adapter (NetworkAdapter) or virtual hard disk (VHD).
      • -VHDPath is the path to the virtual machine disk that you want to use.
      • -Path is the path to store the virtual machine configuration files.
      • -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?.
      • -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. New-VM -Name <Name> -MemoryStartupBytes <Memory> -BootDevice <BootDevice> -VHDPath <VHDPath> -Path <Path> -Generation <Generation> -Switch <SwitchName>

        For example:

        New-VM -Name Win10VM -MemoryStartupBytes 4GB -BootDevice VHD -VHDPath .VMsWin10.vhdx -Path .VMData -Generation 2 -Switch ExternalSwitch This creates a generation 2 virtual machine named Win10VM with 4GB of memory. It boots from the folder VMsWin10.vhdx in the current directory and uses the virtual switch named ExternalSwitch. The virtual machine configuration files are stored in the folder VMData.
    • New virtual hard disk – To create a virtual machine with a new virtual hard disk, replace the -VHDPath parameter from the example above with -NewVHDPath and add the -NewVHDSizeBytes parameter. For example, New-VM -Name Win10VM -MemoryStartupBytes 4GB -BootDevice VHD -NewVHDPath .VMsWin10.vhdx -Path .VMData -NewVHDSizeBytes 20GB -Generation 2 -Switch ExternalSwitch
    • 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 10.
  5. 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. Start-VM -Name <Name>

    For example:

    Start-VM -Name Win10VM
  6. Connect to the virtual machine by using Virtual Machine Connection (VMConnect). VMConnect.exe

Options in Hyper-V Manager New Virtual Machine Wizard

The following table lists the options you can pick when you create a virtual machine in Hyper-V Manager and the defaults for each.

PageDefault for Windows Server 2016 and Windows 10Other options
Specify Name and LocationName: New Virtual Machine. Location:C:ProgramDataMicrosoftWindowsHyper-V.You can also enter your own name and choose another location for the virtual machine. This is where the virtual machine configuration files will be stored.
Specify GenerationGeneration 1You can also choose to create a Generation 2 virtual machine. For more information, see Should I create a generation 1 or 2 virtual machine in Hyper-V?.
Assign MemoryStartup memory: 1024 MB Dynamic memory: not selectedYou can set the startup memory from 32MB to 5902MB. You can also choose to use Dynamic Memory. For more information, see Hyper-V Dynamic Memory Overview.
Configure NetworkingNot connectedYou can select a network connection for the virtual machine to use from a list of existing virtual switches. See Create a virtual switch for Hyper-V virtual machines.
Connect Virtual Hard DiskCreate a virtual hard disk

Name: <vmname>.vhdx

LocationC:UsersPublicDocumentsHyper-VVirtual Hard Disks

Size: 127GB
You can also choose to use an existing virtual hard disk or wait and attach a virtual hard disk later.
Installation OptionsInstall an operating system laterThese options change the boot order of the virtual machine so that you can install from an .iso file, bootable floppy disk or a network installation service, like Windows Deployment Services (WDS).
SummaryDisplays the options that you have chosen, so that you can verify they are correct. – Name
– Generation
– Memory
– Network
– Hard Disk
– Operating System
Tip: You can copy the summary from the page and paste it into e-mail or somewhere else to help you keep track of your virtual machines.

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version