Windows Server 2012 Hyper-V: VM Resource Metering via PowerShell

Windows Server 2012 Logo

With Windows Server 2012 Hyper-V Microsoft introduced a new feature in Hyper-V called Resource Metering which allows you to measure the usage of a virtual machine. This allows you to track CPU, Memory, Disk and network usage. This is a great feature especially if you need to do charge back or maybe even for trouble shooting.

Last week I had the chance to test and implement this feature for a customer.

First you can check the available PowerShell cmdlets for Hyper-V or for the the commands which include VMResourceMetering.

Get-Command VMResourceMetering

The resource metering has to be enabled per Virtual Machine. This is great, so even if you move the virtual machine from one Hyper-V host to another you still have the usage data.

To enable the resource metering you can use the following cmdlet. In my case I enable VM Resource Metering for my VM called SQL2012.



With the cmdlet Measure-VM you can get the statistic for the VM.


To get the network traffic use the properties of the NetworkMeteredTrafficReport.

Measure-VM NetworkMeteredTrafficReport

Here is another great thing, if you want to measure Network from or to a specific network you can use VM Network Adapter ACLs to do so. With ACLs you can not just allow or deny network traffic, you can also meter network traffic for a special subnet or IP address.

add-vmnetworkadapteracl measure-vm

Of course you can reset the statistics for the VM.


And to disable resource metering for the VM use:


I think this is one of the great new features of Windows Server 2012 Hyper-V which gets not a lot of attention but is really important.

If you want to know more about Resource Metering in Hyper-V, checkout the blog post from Lalithra Fernando on the TechNet Virtualization Blog.