Windows Server 2016 Exam – Hyper-V (70-740)

Here are some quick notes to Hyper-V that might come up during the exam:

  • Generations
    Generation 2 is not the default when created a new VM, but using the command -generation 2 during the new-vm applet will accomplish 2.
    * A little copy and paste, Generation 2 features:Generation 2 VMs use synthetic drivers and software-based devices instead, and provide advantages that include the following:
  • Fixed memory can be changed on demand while the VM is running.
  • Network Adapters can be configured while the system is running.
  • UEFI boot Instead of using the traditional BIOS, Generation 2 VMs support Secure Boot, using the Universal Extensible Firmware Interface (UEFI), which requires a system to boot from digitally signed drivers and enables them to boot from drives larger than 2 TB, with GUID partition tables. UEFI is fully emulated in VMs, regardless of the firmware in the physical host server.
  • SCSI disks Generation 2 VMs omit the IDE disk controller used by Generation 1 VMs to boot the system and use a high-performance virtual SCSI controller for all disks, enabling the VMs to boot from VHDX files, support up to 64 devices per controller, and perform hot disk adds and removes.
  • PXE boot The native virtual network adapter in Generation 2 VMs supports booting from a network server using the Preboot Execution Environment (PXE). Generation 1 VMs require you to use the legacy network adapter to support PXE booting.
  • SCSI boot Generation 2 VMs can boot from a SCSI device, which Generation 1 VMs cannot. Generation 2 VMs have no IDE or floppy controller support, and therefore cannot boot from these devices.
  • Boot volume size Generation 2 VMs can boot from a volume up to 64 TB in size, while Generation 1 boot volumes are limited to 2 TB.
  • VHDX boot volume resizing In a Generation 2 VM, you can expand or reduce a VHDX boot volume while the VM is running.
  • Software-based peripherals The keyboard, mouse, and videos drivers in a Generation 2 VM are software-based, not emulated, so they are less resourceintensive and provide a more secure environment.
  • Hot network adapters In Generation 2 VMs, you can add and remove virtual
    network adapters while the VM is running.
  • Enhanced Session Mode Generation 2 VMs support Enhanced Session Mode, which provides Hyper-V Manager and VMConnect connections to the VM with additional capabilities, such as audio, clipboard support, printer access, and USB devices.
  • Shielded virtual machines Generation 2 VMs can be shielded, so that the disk and the system state are encrypted and accessible only by authorized administrators.
  • Storage Spaces Direct Generation 2 VMs running Windows Server 2016
    Datacenter Edition support Storage Spaces Direct, which can provide a highperformance, fault-tolerant storage solution using local drives.Generation 1 is used for backwards compatibility for older versions:Windows Server 2008 R2
    Windows Server 2008
    Windows 7
    Some older Linux distributions
    All FreeBSD distributions
    All 32-bit operating systemsLimitations converting generations:
    While you cannot convert a generation 1 to generation 2, Microsoft does provide a script to convert a generation 2 to generation 1. The script basically omits the features not supported.
    I recommend that you simply create a new VM and configure accordingly.
    Adding disk drives is much easier in 2 since you don’t need to specify the controller, it just adds to the SCSI.
    Export-VM and Import-VM
    Export-VM is very simply and straight forward, but Import-VM adds a little complexity.

    NAME
        Export-VM
    SYNOPSIS
        Exports a virtual machine to disk.
        Example 1
        PS C:\> Export-VM -Name Test -Path D:\
        Exports virtual machine Test to the root of the D drive.
        Example 2
        PS C:\> Get-VM | Export-VM -Path D:\
        Exports all virtual machines to the root of the D drive. Each virtual machine will be exported to its own folder.
    NAME
        Import-VM
    SYNOPSIS
        Imports a virtual machine from a file.
        Example 1
        PS C:\> Import-VM -Path 'D:\Test\VirtualMachines\5AE40946-3A98-428E-8C83-081A3C6BD18C.XML'
        Imports the virtual machine from its configuration file. The virtual machine is registered in-place, so its files are not copied.
        Example 2
        PS C:\> Import-VM -Path 'D:\Test2\Virtual Machines\8F148B6D-C674-413E-9FCC-4FBED185C52D.XML' -Copy -GenerateNewId
        Imports the virtual machine by copying its files to the default virtual machine and virtual hard drive storage locations of the
        Hyper-V host. The imported virtual machine will be given a new unique identifier, not the one in the configuration file. This is
        useful when you want to import multiple copies of a virtual machine, since each virtual machine must have a unique identifier.
        Example 3
        Attempts import of a virtual machine; the attempt fails due to incompatibilities with the Hyper-V host.
        PS C:\> Import-VM -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML'
        Import-VM : Unable to import virtual machine due to configuration errors.  Please use Compare-VM to repair the virtual machine.
        At line:1 char:1
        + import-vm -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XM ...
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : NotSpecified: (:) [Import-VM], VirtualizationOperationFailedException
            + FullyQualifiedErrorId : Microsoft.HyperV.PowerShell.Commands.ImportVMCommand
        Gets a compatibility report that describes the attempted import and lists the virtual machine's incompatibilities with the Hyper-V
        host.
        PS C:\> $report = Compare-VM -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML'
        Displays the compatibility report, revealing that the virtual network adapter was connected to switch Production. The Hyper-V host has
        no switch by that name.
        PS C:\> $report.Incompatibilities | Format-Table -AutoSize
        Message                                      MessageId Source
        -------                                      --------- ------
        Could not find Ethernet switch 'Production'.     33012 Microsoft.HyperV.PowerShell.VMNetworkAdapter
        Disconnects the virtual network adapter.
        PS C:\> $report.Incompatibilities[0].Source | Disconnect-VMNetworkAdapter
        Generates a new compatibility report to determine if the virtual machine is compatible with the Hyper-V host.
        PS C:\> Compare-VM -CompatibilityReport $report
        Displays the compatibility report.
        PS C:\> $report
        VM                 : Microsoft.HyperV.PowerShell.VirtualMachine
        OperationType      : ImportVirtualMachine
        Destination        : HYPER-V-1
        Path               : D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML
        SnapshotPath       : D:\vm1\Snapshots
        VhdDestinationPath :
        VhdSourcePath      :
        Incompatibilities  :
        Imports the virtual machine.
        PS C:\> import-vm -CompatibilityReport $report
        Name State CPUUsage(%) MemoryAssigned(M) MemoryDemand(M) MemoryStatus Uptime   Status             ReplicationState
        ---- ----- ----------- ----------------- --------------- ------------ ------   ------             ----------------
        VM1  Off   0           0                 0                            00:00:00 Operating normally Disabled
        Imports a virtual machine whose configuration is not compatible with the Hyper-V host.

    Versions:
    It’s important to know that each VM you create has a version number that matches the VM HOST. You cannot move Move or Export VMs from a newer version to an older version, but you can move older versions to a newer version VM host. Example, I have a 2012 R2 VM HOST that contains version 5.0 guests, I can import these into a Windows 10 box that runs version 8.1.
    Performance tuning:
    Probably the most difficult thing to plan, monitor, or adjust. If you have unlimited resources this is much easier, but most of the sysadmins do not.
    Enabling monitoring first:

    NAME
        Enable-VMResourceMetering
    SYNOPSIS
        Collects resource utilization data for a virtual machine or resource pool.
        Example 1
        PS C:\> Enable-VMResourceMetering -VMName TestVM
        This example starts collecting resource utilization data on a virtual machine named TestVM.
        Example 2
        PS C:\> Get-VM TestVM | Enable-VMResourceMetering
        PS C:\> Get-VM TestVM | Format-List Name,ResourceMeteringEnabled
        This example starts collecting resource utilization data on a resource pool named TestResourcePool. (You can determine whether
        resource metering is enabled for a resource pool by querying its ResourceMeteringEnabled property.)
        Example 3
        PS C:\> Enable-VMResourceMetering -ResourcePoolName TestResourcePool -ResourcePoolType Memory
        PS C:\> Get-VMResourcePool -Name TestResourcePool -ResourcePoolType Memory | Format-List Name,ResourceMeteringEnabled
        This example uses two commands that show resource metering being enabled and then obtain the data. The first command starts collecting
        resource utilization data for a memory resource pool named TestResourcePool. (You can determine whether resource metering is enabled
        for a resource pool by querying its ResourceMeteringEnabled property.) The second command retrieves the data in and formats it as a
        list.
        Example 4
        PS C:\> Enable-VMResourceMetering -Name TestResourcePool -ResourcePoolType @("Processor","VHD","Ethernet","Memory")
        This example begins collecting resource utilization data on multiple resource pools with the name TestResourcePool.
    

    Starting monitoring

    NAME
        Measure-VM
    SYNOPSIS
        Reports resource utilization data for one or more virtual machines.
        Example 1
        PS C:\> Measure-VM -VMName TestVM
        This example reports resource utilization data for a virtual machine named TestVM.
        Example 2
        PS C:\> $UtilizationReport = Get-VM TestVM | Measure-VM
        PS C:\> Get-VM TestVM | Reset-VMResourceMetering
        This example uses two commands as well as the pipeline. The first command uses the Get-VM cmdlet and passes the object to the
        Measure-VM cmdlet to retrieve collected resource utilization data for a virtual machine named TestVM, and stores the data in a
        variable named $UtilizationReport. The second command uses the Reset-VMResourceMetering cmdlet to clear existing data so that Hyper-V
        begins collecting new data.
    

    Enable Storage Quality of Service (QoS)
    Use the information above to enable quality of service:
    Next, set-vmharddiskdrive -vmname server1 -controllertype scsi –
    controllernumber 0 -minimumiops 10 -maximumiops 500
    Networking:
    Virtual NICs are dynamically assigned MAC address, this can be modified.
    Generation 2 machines’s Network cards will boot PXE, no need for legacy adapters anymore.
    NIC teaming requires at least 2 physical adapters. Once a team is created, you create a Virtual switch to take advantage of the new team.
    VMQ is automatically configured when the machine detects NICs 10 Gbps NICS.
    Configuring VMQ with Powershell:

    NAME
        Enable-NetAdapterVmq
    SYNOPSIS
        Enables VMQ on a network adapter.
        Example 1: Enable VMQ on the specified network adapter
        PS C:\>Enable-NetAdapterVmq –Name "GuestTrafficAdapter"
        This command enables VMQ on the network adapter named GuestTrafficAdapter and restarts the network adapter.

    Powershell version to setup VM NIC teaming:
    new-vmswitch -name setswitch -netadaptername “nic1″,”nic2” –
    enableembeddedteaming $true
    Configure and limit bandwidth to prevent overwhelming the physical adapter:
    set-vmnetworkadapter -vmname server1 -name nic1 –
    minimumbandwidthweight 75
    Powershell Direct:
    I use this for everything when administrating my Virtual Machines, luckily I have a Windows 10 Pro box. Powershell Direct is supported on 2016 and 10 only.