How to create a virtual switch for hyper-v virtual machines

From Microsoft Website:

Create a virtual switch by using Hyper-V Manager

  1. Open Hyper-V Manager, select the Hyper-V host computer name.
  2. Select Action > Virtual Switch Manager.
  3. Choose the type of virtual switch you want.
    Connection typeDescription
    ExternalGives virtual machines access to a physical network to communicate with servers and clients on an external network. Allows virtual machines on the same Hyper-V server to communicate with each other.
    InternalAllows communication between virtual machines on the same Hyper-V server, and between the virtual machines and the management host operating system.
    PrivateOnly allows communication between virtual machines on the same Hyper-V server. A private network is isolated from all external network traffic on the Hyper-V server. This type of network is useful when you must create an isolated networking environment, like an isolated test domain.
  4. Select Create Virtual Switch.
  5. Add a name for the virtual switch.
  6. If you select External, choose the network adapter (NIC) that you want to use and any other options described in the following table.

Setting nameDescription
Allow management operating system to share this network adapterSelect this option if you want to allow the Hyper-V host to share the use of the virtual switch and NIC or NIC team with the virtual machine. With this enabled, the host can use any of the settings that you configure for the virtual switch like Quality of Service (QoS) settings, security settings, or other features of the Hyper-V virtual switch.
Enable single-root I/O virtualization (SR-IOV)Select this option only if you want to allow virtual machine traffic to bypass the virtual machine switch and go directly to the physical NIC. For more information, see Single-Root I/O Virtualization in the Poster Companion Reference: Hyper-V Networking.

If you want to isolates network traffic from the management Hyper-V host operating system or other virtual machines that share the same virtual switch, select Enable virtual LAN identification for management operating system. You can change the VLAN ID to any number or leave the default. This is the virtual LAN identification number that the management operating system will use for all network communication through this virtual switch.

Click OK.

Click Yes.

Create a virtual switch 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. Find existing network adapters by running the Get-NetAdapter cmdlet. Make a note of the network adapter name that you want to use for the virtual switch.
    Get-NetAdapter  
    
  4. Create a virtual switch by using the New-VMSwitch cmdlet. For example, to create an external virtual switch named ExternalSwitch, using the ethernet network adapter, and with Allow management operating system to share this network adapter turned on, run the following command.
    New-VMSwitch -name ExternalSwitch  -NetAdapterName Ethernet -AllowManagementOS $true  
    

    To create an internal switch, run the following command.

    New-VMSwitch -name InternalSwitch -SwitchType Internal  
    

    To create an private switch, run the following command.

    New-VMSwitch -name PrivateSwitch -SwitchType Private  
    

For more advanced Windows PowerShell scripts that cover improved or new virtual switch features in Windows Server 2016, see Remote Direct Memory Access and Switch Embedded Teaming.

Add Hyper-v role on Microsoft Windows Server 2016

Instructions from Microsoft Website:

Install Hyper-V by using Server Manager

  1. In Server Manager, on the Manage menu, click Add Roles and Features.
  2. On the Before you begin page, verify that your destination server and network environment are prepared for the role and feature you want to install. Click Next.
  3. On the Select installation type page, select Role-based or feature-based installation and then click Next.
  4. On the Select destination server page, select a server from the server pool and then click Next.
  5. On the Select server roles page, select Hyper-V.
  6. To add the tools that you use to create and manage virtual machines, click Add Features. On the Features page, click Next.
  7. On the Create Virtual Switches page, Virtual Machine Migration page, and Default Stores page, select the appropriate options.
  8. On the Confirm installation selections page, select Restart the destination server automatically if required, and then click Install.

  9. When installation is finished, verify that Hyper-V installed correctly. Open the All Servers page in Server Manager and select a server on which you installed Hyper-V. Check the Roles and Features tile on the page for the selected server.

Install Hyper-V by using the Install-WindowsFeature cmdlet

  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. To install Hyper-V on a server you're connected to remotely, run the following command and replace <computer_name> with the name of server.

    PowerShell
    Install-WindowsFeature -Name Hyper-V -ComputerName <computer_name> -IncludeManagementTools -Restart  
    

    If you're connected locally to the server, run the command without -ComputerName <computer_name>.

  4. After the server restarts, you can see that the Hyper-V role is installed and see what other roles and features are installed by running the following command:
    PowerShell
    Get-WindowsFeature -ComputerName <computer_name>  
    

    If you're connected locally to the server, run the command without -ComputerName <computer_name>.