Enhanced Session Mode

Enhanced Session Mode (ESM) enables an improved user experience when managing Hyper-V virtual machines. With ESM enabled, an administrator can share devices and the clipboard with a guest VM.  It is also possible to modify the resolution of the VMConnect console.  In addition to improved graphics performance, ESM improves the security of the connection to the guest VM.

The following local resources can be shared via ESM

  • Audio
  • Printers
  • Clipboard (Copy/Paste)
  • USB devices
  • Logical Drives
  • PnP devices
  • Smart Cards

Requirements for Enhanced Session Mode

  • Guest OS supports RDP
    • Client OS: Windows 8.1 Pro/Enterprise
    • Server OS: 2012R2
  • Remote Desktop Service is running in the guest
    • ‘Allow remote connections to this computer’ or NAP do not need to be enabled
  • Hyper-V host must have ‘Enhanced session mode’ enabled in the Hyper-V server settings
  • User must be a member of the local ‘Administrators’ group or a member of the ‘Remote Desktop Users’ group in the guest VM

Enable Enhanced Session Mode

  • In Hyper-V Manager, right click on the host and select ‘ Hyper-V Settings…’.
  • Select the ‘Enhanced Session Mode Policy’ Task Item, then select the check-box labeled ‘Allow enhanced session mode’.
  • If you would like the ESM to be active by default when available select ‘Enhanced Session Mode’ user settings and select the check-box labeled ‘Use enhanced session mode’.

PowerShell Commands

Set-VMHost -EnableEnhancedSessionMode $True

Toggle ESM per VMConnect Instance

Leverage the taskbar icon to enable/disable enhanced session mode for a particular VM connect session.

Additional Resources

TechNet – Use local resources on Hyper-V virtual machine with VMConnect
WindowsItPro – Enhanced Session Mode in Windows Server 2012 R2

Building a Hyper-V Cluster – Using SCVMM to Deploy Host Clusters – Part 4/6

SCVMM Deploying Clusters

In this video we demonstrate how quick and easy it is to create a cluster in SCVMM.


Identify Cluster Name & IP Address To Use

  • If using DHCP address will automatically be assigned
  • Can source from SCVMM IP Pool

Plan LUN usage

  • Witness
  • CSVs

Steps to deploy cluster with SCVMM

1. Verify networks are in place

Verify networks are in place

Verify networks are in place

2. Verify storage is in place

Verify storage is in place

Verify storage is in place

3. Create Cluster Wizard

  • Cluster Name (this is the name you will use for managing the cluster)
  • -Select a runas account that has administrator privileges on the hosts and the ability to create computer account in AD
Create Cluster Wizard

Create Cluster Wizard

4. Select nodes you would like to be included in the cluster

Select nodes you would like to be included in the cluster

Select nodes you would like to be included in the cluster

5. Set cluster IP address from IP Pool, manually define an IP, or leverag DHCP

Set cluster IP address from IP Pool, manually defining an IP, or leveraging DHCP

Set cluster IP address from IP Pool, manually defining an IP, or leveraging DHCP

6. Configure storage LUN uses, format, label and create CSVs

Configure storage LUN uses, format, label and create CSVs

Configure storage LUN uses, format, label and create CSVs

7. Configure virtual switches if appropriate

8. Monitor SCVMM job to verify success

Monitor SCVMM job to verify success

Monitor SCVMM job to verify success

Click ‘View Script’ to see a sample script for deploying cluster programmatically in PowerShell

Script the process

Script the process


TechNet – How to Create a Hyper-V Host Cluster in VMM

Check out the other videos in this series!

Building a Hyper-V Cluster – SCVMM Configuring SMI-S and SMB3 Storage – Part 3/6

SCVMM Configuring SMI-S and SMB3 Storage

As of Windows Server 2012, Microsoft iSCSI Target Server is a server role that enables the server to function as a storage device.

With VMM in System Center 2012 R2, you can manage an iSCSI Target Server running any of several operating system versions:

• With Windows Server 2012 on the iSCSI Target Server: You must first install the necessary SMI-S provider on the iSCSI Target Server. The provider is included in VMM media at   \amd64\Setup\msi\iSCSITargetSMISProvider.msi

• Starting with Windows Server 2012 R2 on the iSCSI Target Server: You only need to install the iSCSI Target Server Role Service and the iSCSI Target Storage Provider Role Service as shown below.

The SMI-S provider follows an “embedded” provider model, where the provider is installed on the iSCSI Target Server computer. The SMI-S provider is WMI-based and manages the iSCSI Target Server by using the iSCSI Target WMI provider.
To install and manage the iSCSI Target Server (2012 R2) with VMM use the following steps:

1. Install the iSCSI Target Server and iSCSI Target Storage Provider as shown above on the server that will become the iSCSI target.
2. Using VMM, on the fabric workspace from the storage area, right-click on providers and add a storage device.
3. Choose the option “SAN and NAS devices discovered and managed by a SMI-S provider”. Click Next.
4. Choose the protocol “SMI-S WMI”, enter the name of the server with the iSCSI target, and choose a Run-AS account.  Click next.
5. The server entered will be scanned, providing the options to choose which local storage devices should be available for presentation by VMM.
6. Once the provider is installed, create LUNs, allocated them to host groups, and add storage to servers as demonstrated in the video.
We can also manage SMB 3.0 shares using VMM.  Windows Server 2012 and 2012 R2 both support SMB 3.0 and can be managed from SCVMM.  To manage SMB shares with VMM follow the steps below:

1. Using VMM, on the fabric workspace from the storage area, right-click on providers and add a storage device.
2. Choose the option “Windows based file server”.  Click Next.
3. Enter the name of the server that you will be managing and using for SMB 3.0 sharing.
4. Complete the wizard to complete adding the provider.
5. Once the provider is configured, add shares to VMM and allocated them to Hyper-V hosts as demonstrated in the video.

Check out the other videos in this series!

Building a Hyper-V Cluster – SCVMM Configuring Networks and Logical Switches – Part 2/6

Configuring Networks and Logical Switches

In part two of the video series we go over how to implement logical networking in System Center Virtual Machine Manager 2012R2 (SCVMM). First we provide an overview of logical networking and why it is a good idea. We then talk about each of the fabric components necessary to implement logical networking. Finally, we implement logical networking in the SCVMM GUI then show the process for implementation with PowerShell.

Logic Networking Overview

Logical networks provide a way for administrators to represent the physical network configuration in the virtual environment. This enables many features such as delegating access to network segments to specific user roles. It also eases the deployment of converged networking and can help ensure all of your Hyper-V hosts have identical network configuration. If someone makes a change to the network configuration in Hyper-V manager or Failover Cluster manager the host will be flagged as not compliant in SCVMM. The network configuration deployed via logical networking resides on the Hyper-V hosts and is not dependent on SCVMM to stay online. This configuration survives reboots even if SCVMM is offline.

When deploying logical networks the management IP must be available the entire time the switches are deployed. This can be challenging when a system only has two NICs as the management VLAN must be available as both tagged and untagged (native). Systems using more than two adapters are easier to configure as the management interface can be can be deployed locally before the system is imported into SCVMM.

Some of the logical networking features can be used when importing Hyper-V hosts with an existing virtual switch. SCVMM will detect existing configurations as ‘Standard Switches’. The administrator must manually select the logical networks in the properties of the host hardware to use virtual networks.

Networking Concepts

This diagram shows how all of the fabric components in SCVMM relate to one another.
Logical Network Components

VM Network

This component allows you to assign a network segment (VLAN) to a virtual adapter. It is created under ‘VMs and Services’ rather than Fabric-Networking. One VM network will typically be associated with one network segment. This gives the network segment a friendly name that can be used so that users do not need to know subnets or VLANIDs. It also can have permissions assigned so that only certain users can select the network segment in their virtual machines.

Logical Network

Logical networks represent a group of network segments. Logical networks may group network segments in many ways:

  • Single segments or VLAN
  • All Production segments in all sites
  • All segments in a single site

Logical Network – Network Site

Logical network have a subcomponent called a network site. A network site can be used to associate network segments with host groups. Multiple sites can exist in a single logical network. Network sites are primarily used to represent geographies or unique areas such as a DMZ.

Logical Network – Network Site – Subnet / VLAN

Subnets and VLANs can be defined within the network site. Subnets/VLANs are used to associate one or more network segments within a site. You do not have to populate the subnet field in all cases.

IP Pool

This component is used to associate a range of IP Address with a network segment. VMM can then assign these addresses statically to VMs or Hyper-V hosts.

Port Profile

Two types of port profiles exist, ‘Uplink’ and ‘Virtual Adapter’. Uplink port profiles are used to represent the network segments (VLANs) in the configuration of a physical switch port to which a Hyper-V host is connected. It is also used to define the teaming and load balancing mode for a host.

Virtual Adapter port profiles provide a way to create a collection of setting pertaining to virtual adapters. These profiles can define settings such a network optimization, security and QoS. Virtual adapter port profiles are assigned to virtual adapters in VMs and Hyper-V hosts.

Logical Switch

The logical switch component is a vSwitch deployed by SCVMM employing a network topology and configuration defined by the components listed above. It is not possible to import existing Hyper-V network configurations into SCVMM as logical switches. Both the LBFO Team and the vSwitch must be created by SCVMM. By forcing deployment with SCVMM this ensures configuration uniformity among the hosts where it is deployed.

A logical switch will have an association with one or more virtual adapter port profiles. It will also have at least one uplink port profile. When deploying a logical switch one uplink port profile is selected and this will determine the teaming and load balance modes for the vSwitch. Logical networks are the last network fabric component deployed as they depend on the other fabric components.

Example Configuration

Example Logical Network
In the video we deploy a sample configuration with two data center sites. These sites have several network segments each. The segments are grouped into 3 logical networks: Dev, Backup and Prod. Dev is only in Las Vegas while Prod is in both datacenters. Prod uses a different VLAN ID in each data center. Backup is a single stretched VLAN. Two uplink port profiles are created to describe the two possible switch port configuration for the Hyper-V hosts. In this case the switch ports are uniformly configured within a site, so one port profile is required for the Seattle datacenter and a second for the Las Vegas datacenter. These port profiles can be used to create two possible logical switches: Host and Virtual Machine. In our example we use separate physical adapters for the host traffic and the VM traffic.


TechNet – Configuring Logical Networking in VMM Overview
TechNet – Configuring VM Networks in VMM Illustrated Overview
MSDN Blog – Building a teamed virtual switch for Hyper-V from SCVMM

Check out the other videos in this series!

Building a Hyper-V Cluster – SCVMM Installation and Introduction – Part 1/6

SCVMM Installation and Introduction

In this video the focus is on the installation of SCVMM and an introduction to the console. Viewers of this video will learn the installation scenarios for SCVMM, software requirements, hardware requirements, and the requirements for installing SCVMM into a virtual machine. Installation considerations will be discussed, including the use of service accounts in AD and the distributed key management store in AD. Finally, the video ends in a complete demo of installation, and a walk-through of the console.

Installation Scenarios

For small environments with less than 500 VMs, fewer than 20 hosts and fewer than 5 administrators it is possible to install VMM in an all in one virtual machine running the library and database locally. Larger environments will experience performance benefits from splitting out database components. For very large environments, it may be better to dedicate physical resources to both the database and also the SCVMM server. It may be advantageous to split the library role onto another system if you expect to be storing many VMs or templates in the library. When using a VM, it is best practice to dedicate a VHDX file for the library. This will make it easier to deal with growth of the library data long term.

Another consideration to make is running SCVMM in a highly available configuration. If SCVMM is running inside a virtual machine on a cluster, then the service is already protected from hardware failures. If the VM experiences a software issue, such failed software maintenance, the physical cluster will not protect against this kind of outage. To protect against guest OS issues the SCVMM installation itself can also be clustered.

Software Requirements

Before beginning the installation of SCVMM the following software prerequisites exist for the computer you install SCVMM on:

    • Operating System must be at least Windows Server 2012 or 2012R2
    • Operating System can be Standard or Datacenter edition
    • Operating System can run Server with a GUI or Server Core
    • The system must be a member of an Active Directory Domain
    • The name of the computer must not exceed 15 characters and must not contain ‘-SCVMM’
    • WinRM3.0 (or greater) service set to start automatically (this is included in the Windows install)
    • Microsoft .NET Framework 4 or 4.5 (this is included in the Windows install)
    • Windows ADK for Windows 8 – Available from Microsoft Download Center
  • Supported version of SQL Standard/Enterprise (MSSQL 2008R2 or MSSQL 2012)
  • SQL Native Client and SQL Server Command Line Utilities matching SQL version used
    SQL Server 2008 R2 Feature Pack (look in installation instructions for the actual file download
    SQL Server 2012 Feature Pack (look in installation instructions for the actual file download)-

Hardware Requirements

The following requirements exist for the system you are installing VMM on:

  • 4 cores @ 3.6Ghz (2 cores for environments with less than 150 hosts)
  • 8GB RAM (Install will fail below 2GB and give a warning with less than 4GB)
  • 10GB Free Hard disk space for remote SQL and library, at least 150GB for local library and SQL install

Can SCVMM run on a VM?

Running SCVMM in a Virtual Machine is fully supported and a common practice. VMM can manage the same host where the SCVMM VM is running. If this is the scenario you plan to deploy simple be cognizant that changes you make to the cluster SCVMM is hosted on my have an impact on your ability to reach the SCVMM server. Avoid performing ‘Quick Migration’ on the VM and instead opt for Live Migrations.

If you are using a Virtual Machine with Dynamic Memory enable to run SCVMM it is recommended to set the startup memory to 4GBs. This will prevent the installer from generating a low memory warning and will ensure the VM has the baseline amount of memory for acceptable performance.

Installation Considerations

Here are a few additional details you should keep in mind when performing the SCVMM installation:

  • You must be an Administrator on the server where VMM will be installed
  • It is recommended you prepare a service account in Active Directory for SCVMM (required for HA VMM installs)
  • Prepare a DKM store in AD for DB Encryption Key Storage (Required for HA VMM Installs)

Distributed Key Management Store

By default, without DKM storage SVMM will store the database encryption keys in the registry. This complicates recovery if the VM should be lost and also is not supported for HA installations of VMM. By enabling DKM storage during the SCVMM install the encryption keys are stored in Active Directory. Before you begin the SCVMM installation, you should ensure you have created a container in the AD DS. You can use ADSI to create this container as demonstrated in the video. Ensure that the service account for VMM has the ‘Full Control’ permission on the container. Creating and assigning permissions to this container will require an account with Domain Admin privileges.


TechNet – System Requirements: VMM Management Server in System Center 2012 and in System Center 2012 SP1
TechNet – How to Install a VMM Management Server
MSDN – Installing the Windows ADK
TechNet – Virtual Machine Manager
TechNet – Configuring Distributed Key Management in VMM

Check out the other videos in this series!

Deploying and Using SCVMM – Part 0/6

In this Quick Start Series we will show you how quickly and easily you can set up your own SCVMM and Hyper-V cluster.  In this series we are using Server 2012R2, iSCSI Target Server for shared storage and SCVMM as a single management interface for the virtual infrastructure.  In each video we will show you how to install and configure the various components to set up a Microsoft virtualization solution leveraging SCVMM.  We will show how to perform these configuration operations in GUI and then again in PowerShell.
To reproduce the environment in this video series you need:
  • 2 physical computers for Hyper-V hosts
  • 1 VM/Physical server for iSCSI target software (Running Windows 2012R2)
  • 1 VM/Physical server for SCVMM (Running Windows 2012R2)
  • Install any Windows Server 2012R2 SKU Core/Full
  • Network connectivity with at least 1 NIC between all the systems

Video 1 – SCVMM Installation & Introduction
Video 2 – Configuring Networks & Logical Switches
Video 3 – Configuring SMI-S  and SMB3 Storage
Video 4 – Deploy Clusters In VMM
Video 5 – SCVMM Patch Management
Video 6 – SCVMM VM Management

Hyper-V Unknown Devices

Hyper-V Unknown Devices

In Windows Server 2012 R2 Hyper-V, Microsoft made a couple of enhancements within virtual machines that provide new capabilities for guests that support the associated features.  These features include Automatic Virtual Machine Activation, and Enhanced Session Mode.

 Automatic Virtual Machine Activation

Automatic Virtual Machine Activation provides customers with an easier way to manage VM guest license activations when their VMs are running on a Datacenter Edition of Windows server 2012 R2.  Because Datacenter Edition provides unlimited virtual machine licenses for Windows Server VMs, VMs running Windows Server 2012 R2 on 2012 R2 hosts will be automatically activated, reducing the effort of administrators for purposes of license activation.

 Enhanced Session Mode

Enhanced Session Mode provides administrators with enriched tools for interacting with virtual machines through the console connection.  In previous versions of Hyper-V, administrators could connect to VMs using Virtual Machine Connection, which had limited functionality, particularly if you wanted to copy and paste something into your VM.  Now with 2012 R2 Hyper-V, guests with supported operating systems provide true RDP capabilities, but via the VMBus, which means these connections can be made without a network connection.

Below is a Device Manager windows for a Windows Server 2008 guest running in a Windows Server 2012 R2 Hyper-V VM. Note the two Unknown devices:

Device manager showing two unknown devices in a 2008R2 Hyper-V guest

Device manager showing two unknown devices in a 2008R2 Hyper-V guest

Taking a look at the Properties of each device and specifically look at the Hardware IDs, we can see one that starts with 3375. This is the new virtual device used for Automatic Virtual Machine Activation.

Hardware ID for Automatic Activation in Hyper-V 2012R2

Hardware ID for Automatic Activation in Hyper-V 2012R2

Looking at the Properties and Hardware IDs on the other device, we see that it starts with f8e6. This is the new virtual device used for Enhanced Session Mode.

Hardware ID for Enhanced Session Mode in a 2012R2 Hyper-V Guest

Hardware ID for Enhanced Session Mode in a 2012R2 Hyper-V Guest

Automatic Virtual Machine Activation and the new Enhanced Session Mode features are new to Windows Server 2012 R2 and later, thus earlier guests (Windows Server 2012 and earlier) don’t know what these devices are and show these as unknown devices.  These unknown devices can be safely ignored in the older operating systems.

Additional Resources

TechNet: Virtual Machine Connection – Enhanced Session Mode Overview
MSDN Code: Hyper-V enhanced session mode sample
TechNet: Automatic Virtual Machine Activation

Hyper-V Resource Metering

Hyper-V Resource Metering

In this video we explore the new resource metering features in Hyper-V 2012 and 2012R2. We talk about the structure and uses of resource metering and then we use PowerShell to implement resource metering on a clustered configuration.

Resource Metering Overview

Resource metering enables administrators to collect data about the resource usage of a VM or pool of VMs. This data is presented as average utilization over a time period. The time period is the time sense the metering was enabled, or sense the last metering reset. This data can be used for creating chargeback or show back models. As you will soon see, the data from resource metering is relatively simple. It is not meant to replace an enterprise performance monitoring tool such as System Center Operations Manager (SCOM). Resource metering is something that can only be configured via the PowerShell interface.

Resource metering allows you to collect information about the VM’s CPU, memory, network and storage utilization. The data collected is stored in the virtual machine’s configuration file. This means that the resource metering data will stay with the VM when it is migrated to another host or cluster node.

A hierarchy of resource pools can be created to group VMs. The groups can represent any logical collection that is meaningful in your environment. A VM’s resource may only belong to one resource group at a time. The resource group gets its totals from the data stored in the VM’s configuration files. As such, if a host has no VMs on it, its resource groups will not report any values and will be disabled. When creating a resource pool a ‘pool type’ must be defined. While it is possible to configure different names for each of the resource pool types, it may be easier to name all of the pools for a particular logical collection with the same name as we have done in the video. This makes collecting the data much easier, but is not a requirement.

PowerShell Command to Manage Resource Metering

Enable/Disable Resource Metering
Configure VM Resources for Metering
Creating/Removing Resource Pools
Measuring VMs and Pools

Resource Metering Demo!

In the video we did a demo where we created resource pools called Pool1 on cluster HVC0 for our 3 VMs (App-1,2,3). We then gathered pool metering information from all of the nodes and displayed the aggregated data.
Here is the script that we used in the video:

PowerShell Code for Resource Metering

###Demo 1 functions - Demo 1 Enable VM and Measure
###Show Cluster Resource Pool
function Get-ClusterResourcePool {
    param ($Cluster = ".",$ResourcePool = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    Get-VMResourcePool -ComputerName $nodes -Name $ResourcePool
### Enable Cluster Resource Metering VM
function Enable-ClusterResourcePoolVM {
    param ($Cluster = ".", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $VMS = Get-VM -ComputerName $Nodes -VMName $VMFilter -ErrorAction SilentlyContinue
    if($VMs){ #VMs found!
        $VMs |Enable-VMResourceMetering
    } else {
        "No Vms Match Filter"
### Measure Cluster Resource Pool VMs
function Measure-ClusterResourcePoolVM{
    param ($Cluster = ".", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    Measure-VM -ComputerName $nodes -Name $VMFilter -ErrorAction SilentlyContinue

#Demo 1 Enable VM and Measure
Get-ClusterResourcePool -Cluster HVC0
Enable-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App*
start-vm -ComputerName HVC0N1 -Name App-2
Get-ClusterResourcePool -Cluster HVC0
Measure-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App-*
stop-vm -ComputerName HVC0N1 -Name App-2

###Demo 2 functions

###Create Cluster Resource Pool
Function New-ClusterResourcePool {
    param ($Cluster = ".", $ResourcePool = "Pool1", $StoragePath = "NoneSupplied", $SwitchName="HVSwitch")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    New-VMResourcePool -ComputerName $Nodes -Name $ResourcePool -ResourcePoolType Ethernet,Processor,Memory
    If ($StoragePath -eq "NoneSupplied"){$StoragePath = (Get-ClusterSharedVolume -Cluster $cluster| select -ExpandProperty sharedVolumeInfo).friendlyvolumename}
    New-VMResourcePool -ComputerName $Nodes -Name $ResourcePool -ResourcePoolType VHD -Paths $StoragePath
    Get-VMSwitch -ComputerName $Nodes -Name $SwitchName| Add-VMSwitch -ResourcePoolName $ResourcePool
### Set Cluster Resource Pool VM Assignment
Function Set-ClusterResourcePoolVM {
    param ($Cluster = ".",$ResourcePool="Primordial", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $VMS = Get-VM -ComputerName $Nodes -VMName $VMFilter -ErrorAction SilentlyContinue
    if($VMs){ #VMs found!
        foreach ($VM in $VMS) {
            Write-Debug "Setting resource pool $ResourcePool on VM $($VM.name)"
            $VM|Set-VMProcessor -ResourcePoolName $ResourcePool
            $VM|Set-VMMemory -ResourcePoolName $ResourcePool
            $VM|Get-VMNetworkAdapter| Set-VMNetworkAdapter -ResourcePoolName $ResourcePool
            $VM|Get-VMNetworkAdapter| Connect-VMNetworkAdapter -UseAutomaticConnection #ENABLES LIVE MIGRATION BETWEEN HOSTS IN CLUSTER
            $VM|Get-VMHardDiskDrive| Set-VMHardDiskDrive -ResourcePoolName $ResourcePool
    } else {#no vms found!
        "No VMs match filter"
### Get Cluster Resource Pool VM Assignment
Function Get-ClusterResourcePoolVM {
    param ($Cluster = ".", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $VMS = Get-VM -ComputerName $Nodes -VMName $VMFilter -ErrorAction SilentlyContinue
    if($VMs){ #VMs found!
        foreach ($VM in $VMS) {
            Write-Debug "Getting resource pool info for VM $($VM.name)"
            $MyObj = ""| select VM, CPU, RAM, Disk, Network
            $MyObj.VM = $VM.name
            $Myobj.CPU = $vm| Get-VMProcessor|select -ExpandProperty ResourcePoolName
            $MyObj.RAM = $vm| Get-VMMemory|select -ExpandProperty ResourcePoolName
            $MyObj.Network = ($vm| Get-VMNetworkAdapter|select -ExpandProperty PoolName|select -Unique) -join ","
            $MyObj.Disk = ($vm| Get-VMHardDiskDrive|select -ExpandProperty PoolName|select -Unique) -join ","
    } else {#no vms found!
        "No VMs match filter"
### Measure Cluster Resource Pool
function Measure-ClusterResourcePool {
    param ($Cluster = ".",$ResourcePool)
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $Pools = Get-VMResourcePool -ComputerName $Nodes | where-Object { $_.ResourceMeteringEnabled -eq "True"}|%{$_.name}| Select-Object -Unique
    foreach ($Pool in $Pools){
        $MyObj = ""| select PoolName,  AvgCPU, AvgRAM, TotalDisk, NetworkInbound, NetworkOutbound
        $MyObj.PoolName = $Pool
        $MyObj.AvgCPU = (Measure-VMResourcePool -ComputerName $nodes -name $pool -ResourcePoolType Processor `
                             -ErrorAction SilentlyContinue|Measure-Object -sum -Property AvgCPU).sum
        $MyObj.AvgRAM = (Measure-VMResourcePool -ComputerName $nodes -name $pool -ResourcePoolType Memory -ErrorAction SilentlyContinue|Measure-Object -sum -Property AvgRAM).sum
        $MyObj.TotalDisk = (Measure-VMResourcePool -ComputerName $nodes -name $pool -ResourcePoolType VHD -ErrorAction SilentlyContinue|Measure-Object -sum -Property TotalDisk).sum
        $networkGroup = Measure-VMResourcePool -computername $nodes -name $pool -ResourcePoolType Ethernet -ErrorAction SilentlyContinue | select -ExpandProperty NetworkMeteredTrafficReport|Group-Object -Property direction
        $MyObj.NetworkInbound  =  ($networkGroup|?{$_.name -eq "Inbound"}|select -ExpandProperty group|Measure-Object -Property TotalTraffic -Sum).sum
        $MyObj.NetworkOutbound  =  ($networkGroup|?{$_.name -eq "Outbound"}|select -ExpandProperty group|Measure-Object -Property TotalTraffic -Sum).sum

#Demo 2 Create, assign and measure pool
New-ClusterResourcePool -Cluster HVC0 -ResourcePool Pool1
Get-ClusterResourcePool -Cluster HVC0
Get-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App* | Format-Table -AutoSize
Set-ClusterResourcePoolVM -Cluster HVC0 -ResourcePool pool1 -VMFilter App*
Get-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App* | Format-Table -AutoSize
Start-VM -ComputerName (Get-ClusterNode -Cluster HVC0).name -Name App*
Measure-ClusterResourcePool -Cluster HVC0 -ResourcePool pool1

###Demo 3 functions
### Reset Cluster Resource Metering VM
function Reset-ClusterResourcePoolVM {
    param ($Cluster = ".", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $VMS = Get-VM -ComputerName $Nodes -VMName $VMFilter -ErrorAction SilentlyContinue
    if($VMs){ #VMs found!
        $VMs |Reset-VMResourceMetering
    } else {
        "No Vms Match Filter"
### Reset Cluster Resource Metering
function Reset-ClusterResourcePool {
    param ($Cluster = ".",$ResourcePool="*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    Reset-VMResourceMetering -ComputerName $nodes -ResourcePoolName $ResourcePool -ErrorAction SilentlyContinue

#Demo 3 Reseting resource metering
Stop-VM -ComputerName (Get-ClusterNode -Cluster HVC0).name -Name App*
measure-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App*
Reset-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App-2
measure-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App*
Reset-ClusterResourcePool -Cluster HVC0 -ResourcePool pool1
measure-ClusterResourcePool -Cluster HVC0 -ResourcePool pool1

#Demo 4 functions
### Disable Cluster Resource Metering VM
function Disable-ClusterResourcePoolVM {
    param ($Cluster = ".", $VMFilter = "*")
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    $VMS = Get-VM -ComputerName $Nodes -VMName $VMFilter -ErrorAction SilentlyContinue
    if($VMs){ #VMs found!
        $VMs |Disable-VMResourceMetering
    } else {
        "No Vms Match Filter"
###Remove Cluster Resource Pool
function Remove-ClusterResourcePool {
    param ($Cluster = ".",$ResourcePool)
    $Nodes = (Get-ClusterNode -Cluster $Cluster).name
    Remove-VMResourcePool -ComputerName $Nodes -Name $ResourcePool -ResourcePoolType Ethernet,Processor,Memory,VHD

#Demo 4 Remove resource pools
Set-ClusterResourcePoolVM -Cluster HVC0 -ResourcePool "Primordial" -VMFilter App*
Disable-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App*
Remove-ClusterResourcePool -Cluster HVC0 -ResourcePool pool1
Get-ClusterResourcePool -Cluster HVC0
Get-ClusterResourcePoolVM -Cluster HVC0 -VMFilter App*| Format-Table * -AutoSize


TechNet: Introduction to Resource Metering
MSDN: Hyper-V Resource Metering Overview

Hyper-V dVMQ

Deep Dive: Configuring dVMQ in Hyper-V

Virtual Machine Queue (VMQ) is a mechanism for mapping physical queues in a NIC to the virtual NIC in a VM partition (Parent or guest). This mapping makes the handling of network traffic more efficient. The increased efficiency results in less CPU time in the parent partition and reduced latency of network traffic. Also, without VMQ, traffic for a vSwitch on particular network interface is all handled by a single CPU core. This limits total throughput on a 10GB interface to ~2.5-4.5GBits/sec (results will depend on speed of core and nature of traffic). VMQ is especially helpful on workloads that process a large amount of traffic, such as backup or deployment servers. For dVMQ to work with RSS, the parent partition must be running Server 2012R2, otherwise RSS can not coexists with VMQ.

VMQs are a finite resource. A VMQ is allocated when a virtual machine is powered on. A queue will be assigned to each vNIC with VMQ enabled until all of the VMQs are exauted. That assignment will remain in place until the VM is powered off or migrated to another hyper-v node. If you have more vNICs in your environment than VMQs on your physical adapter then you should only enable VMQ on the vNICs that will be handling the most traffic.

Static VMQ

This image represents a Hyper-V host configured without VMQ in place. All network traffic for all the VMs is handled by a single core. With static VMQ (available in 2008R2), a VMQ is assigned to a specific CPU, and will stay on the CPU independent of workloads.

Dynamic VMQ

This image introduces both Dynamic Virtual Machine Queue (dVMQ) and load balancing mode for NIC teaming. These features are new to Server 2012. dVMQ is very similar to VMQ with one major difference. Dynamic VMQ will scale the number of CPU cores used to handle the VMQs across pool of CPU cores. When the network workloads are light all the dVMQs will be handled by a single CPU core, but as the network workload increases so too will the number of CPU cores used. With dVMQ in 2012 each queue can only use one CPU core at a time. Also, a vNIC can only have one VMQ assigned to it.

Sum Mode/Min Mode

In our video we recommend Hyper-V Port AND Switch Independent for a Load Balance Failover Team (LBFO) configuration on switches supporting Hyper-V workloads. This load balancing mode and teaming mode will put the vSwitch in Sum mode. This mean that we will have the sum of all the VMQs from the NICs in the LBFO team. In the case of the left image above we have 2 NICs in the team each with 2 VMQs. With the team in Sum mode we have a total of 4 VMQs to allocate to vNICs. If we use AddressHash OR Switch Dependent configuration on the team, it will be placed in Min mode. In the right image above, the same hardware now only offers 2 VMQs for vNICs. This is because inbound traffic may come in on any network interface on the team for a particular vNIC. This may be a desirable configuration if you have very few vNICs on a vSwitch (vNIC count equal or less than the fewest VMQs on any NIC in the team).

Virtual Receive Side Scaling

Server 2012R2 introduces Virtual Receive Side Scaling (vRSS). This feature works with VMQ to distribute the CPU workload of recive traffic across multiple CPU cores in the VM. This effectively eliminates the CPU core bottleneck we experience with a single vNIC. To take full advantage of this feature both the host and guest need to be 2012R2. Enabling vRSS does come with the cost of extra CPU load in the VM and parent partition. For this reason, vRSS should only be enabled on vNICs that will be exceeding 2.5GBits/Sec on a regular basis.

Base and Max CPU

Base and Max CPU properties are used to configure what CPU cores will be used by VMQ.  The base processor is the first core in the group and max is the size of the group.  For example, Hyper Threading disabled and base=2 max=4 would assign cores 2-5.  VMQ will not leverage hyper threading (HT).  If HT is enabled then only even numbered cores will be used.  For example: HT enabled, base=2 max=4 would assign even numbered cores 2-8.  When ever possible it is best to choose a base value greater than 0 (or 1 in case of HT).  Creating CPU bottlenecks on core 0 has caused performance issues in some implementations.

Requirements and Configuration for VMQ

The following are required to use VMQ:
-Server 2008R2 (Static VMQ), Server 2012(dVMQ), Server 2012R2 (dVMQ+vRSS)
-Physical NICs must support VMQ
-BelowTenGigVmqEnabled = 1 for 1GB NICs (10GB NICs are auto enabled)
Follow these steps from the video to enable VMQ
0. Enable VMQ for 1GB if required
–HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMSMP\Parameters\BelowTenGigVmqEnabled = 1
1. Install the latest NIC driver/firmware
2. Enable VMQ in the driver for the NIC (Process will vary by NIC model and manufacturer)
3. Determine values for Base and Max CPU based on hardware configuration
4. Assign values for Base and Max CPU
5. Configure VMs

Recommendations for VMQ/dVQM/vRSS

-Use Switch Independent + Hyper-V Port to ensure the vSwitch is in SUM mode
-Always assign a base CPU other than CPU0 to ensure best performance and resiliency
-Remember when assigning Base/Max CPU using HyperThreading only even numbered cores are used
-Multiplexor Adaptors will show Base:Max of 0:0, do not change this item
-Configure Base and Max CPU for each NIC with as little overlap as possible
-Only assign Max Processor values of 1,2,4,8
–It is ok to have max processor extend past the last CPU core or number of VMQs on the NIC

Troubleshooting VMQ

Here are a few things we have seen in the field when supporting VMQ

  • Most issues with VMQ are resolved by updating to the latest version of the NIC driver!
  • VMQ appears enabled but is showing 0 queues. This may even only impact a single port on a multiport NIC.
    • *RssOrVmqPreference = 1 Must be set on all NICs that will leverage VMQ (Follow this Link for more information)
    •  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318\[GUID of NIC Port]\*RssOrVmqPreference = 1

If you have an issue that you have experienced in your environment not listed here let me know so I can add it to the list!

PowerShell Code to Auto Configure VMQ Base/Max Processor


$Teams = Get-NetLbfoTeam
$proc = Get-WmiObject -Class win32_processor
$cores = $proc| Measure-Object -Property NumberOfCores -Sum|select -ExpandProperty sum
$LPs = $proc| Measure-Object -Property NumberOfLogicalProcessors -Sum|select -ExpandProperty sum
$HT = if($cores -eq $LPs){$false}else{$true}
function SetVMQsettings ($NIC, $base,$max){
    #$nic|Set-NetAdapterVmq -BaseProcessorNumber $base -MaxProcessors $max
    Write-Host "$($nic.name):: Proc:$base, Max:$max"
#$LPs = 4 #testing var
#$ht = $false #testing var
foreach ($team in $teams){
	$VmqAdapters = Get-NetAdapterVmq -name ($team.members)
	#Create settings
	$VMQindex = 0
	Foreach($VmqAdapter in $VmqAdapterS){
		$VmqAdapterVMQs =$VmqAdapter.NumberOfReceiveQueues
        #$VmqAdapterVMQs = 2 #testing var
		if ($VMQindex -eq 0){#first team nic
			#base proc 1+HT and max eq to num remaining cores, num queues, whatever is less
			$base = 1+[int]$ht
			$max = ($LPs/(1+$HT)-1), $VmqAdapterVMQs|sort|select -Index 0
            SetVMQsettings -nic $VmqAdapter -base $base -max $max
        else{#all other nics exclusing first team nic
            if ($VmqAdapterVMQs -gt ($LPs/(1+$HT))){ #queues exceeds core count, so just start at base+1
                $base = 1+[int]$ht
                $max = ($LPs/(1+$HT)-1), $VmqAdapterVMQs|sort|select -Index 0
                SetVMQsettings -nic $VmqAdapter -base $base -max $max
            else{ #cores greater than Queues so ballancing is possible
                $StepSize = [int]((($LPs/(1+$HT))-$VmqAdapterVMQs-1)/($VmqAdapters.count-1))*$VMQindex+1
                $base = $StepSize * (1+$HT)
                $max = ($LPs/(1+$HT)-1), $VmqAdapterVMQs|sort|select -Index 0
                SetVMQsettings -nic $VmqAdapter -base $base -max $max


TechNet Networking Blog: Deep Dive VMQ Part 1, 2, 3

Building a Hyper-V Cluster – Creating Virtual Machines – Part 5/5

Creating and Managing VMs

In this video we will create highly available VMs.  First we create the virtual machines in the GUI then in PowerShell.

When creating a VM, ensure that you always check the box to store the virtual machine in a different location.  If you don’t do this, then the VM’s configuration file and VHD files will be put in the Hyper-V default location.  This is bad because it will be hard to tell what VHDs are associated configuration files.  If you check the store virtual machine in a different location check box all of the VM’s components will be stored in a single folder.  This will make your management life much easier!  Also, if the VM will be part of the cluster, be sure to create and manage the VM in failover cluster manager rather than Hyper-V manager.

Store the virtual machine in a different location

PowerShell PowerShell Code

#Create a new VM
New-VM -Name JasonVM -Path c:\ClusterStorage\CSV1

#Add the VM to the cluster so it becomes highly available
Add-ClusterVirtualMachineRole -VMName JasonVM

#Start the VM and live migrate it to another cluster node
Start-ClusterGroup -Name JasonVM
Move-ClusterVirtualMachineRole -Name JasonVM

#Create and remove VM Snapshot/Checkpoints
Checkpoint-VM -Name JasonVM
Get-VM -Name JasonVM| Get-VMSnapshot
Get-VM -Name JasonVM| Get-VMSnapshot| Remove-VMSnapshot

#Shut down the VM
Stop-VM -Name JasonVM

#List the Hyper-V and Failover Clustering commands
Get-Command -Module hyper-v, failoverclusters


MSDN: Virtual Machine Live Migration Overview
TechNet:Windows PowerShell: Create Hyper-V virtual machines

Check out the other post in this series!