How to Configure Windows Server 2016 Hyper-V Resource Metering
Hyper-V Resource Metering in Windows Server 2016 provides a built-in mechanism for tracking the resource consumption of virtual machines. It allows administrators and service providers to measure CPU utilisation, memory usage, network traffic, and disk I/O on a per-VM basis. The collected data can be used for chargeback, capacity planning, and performance analysis without requiring third-party monitoring tools. This tutorial explains how to enable, configure, query, and reset Hyper-V Resource Metering using both Hyper-V Manager and PowerShell.
What Resource Metering Tracks
Hyper-V Resource Metering records four categories of data for each virtual machine over a defined measurement interval. Average CPU usage is expressed in megahertz (MHz) relative to the physical processor speed, giving a fair comparison across hosts with different processor speeds. Average memory usage captures the average amount of RAM (in megabytes) consumed by the VM during the interval, accounting for dynamic memory balloon fluctuations. Network I/O records the total inbound and outbound bytes transmitted through each virtual network adapter. Disk I/O records the total bytes read and written across all virtual hard disks attached to the VM.
Prerequisites
You need a Windows Server 2016 host with the Hyper-V role installed and at least one virtual machine configured. No additional roles or features are required. All PowerShell commands should be run in an elevated PowerShell session on the Hyper-V host. Hyper-V Resource Metering is disabled by default on all VMs; you must explicitly enable it for each VM you wish to monitor.
Step 1: Enable Resource Metering on a Virtual Machine
Open an elevated PowerShell session on the Hyper-V host and run the following command to enable resource metering for a specific VM. Replace “WebServer01” with the name of your virtual machine.
Enable-VMResourceMetering -VMName "WebServer01"
To enable resource metering for all virtual machines on the host at once, use the wildcard approach:
Get-VM | Enable-VMResourceMetering
Once enabled, Hyper-V immediately starts accumulating resource consumption data for the VM. The metering counters begin at zero from the point of enablement.
Step 2: Query Resource Metering Data
To retrieve the accumulated resource consumption data for a VM, use the Measure-VM cmdlet. This returns an object containing all four resource categories.
Measure-VM -VMName "WebServer01"
The output includes the VM name, average CPU usage in MHz, average memory demand in MB, aggregate network I/O in bytes, aggregate disk I/O in bytes, and the duration of the measurement period. To format this into a readable table, pipe the output to Format-List:
Measure-VM -VMName "WebServer01" | Format-List *
To query all VMs at once and export the results to a CSV file for further analysis:
Get-VM | Measure-VM | Select-Object VMName, AvgCPU, AvgRAM, TotalDisk, TotalNetwork | Export-Csv -Path "C:ReportsVMMetering.csv" -NoTypeInformation
Step 3: Understand the Output Properties
The Measure-VM cmdlet returns several important properties. AvgCPU is the average CPU usage in MHz. AvgRAM is the average memory demand in MB. TotalDisk is the total bytes of disk I/O (reads and writes combined). TotalNetwork is the total bytes of network I/O (inbound and outbound combined). MeteringDuration indicates how long data has been collected since the last reset.
For network adapter-level granularity, the NetworkMeteredTrafficReport property contains per-adapter breakdowns including inbound and outbound byte counts:
(Measure-VM -VMName "WebServer01").NetworkMeteredTrafficReport
Step 4: Configure Resource Metering Intervals
By default, Hyper-V updates the resource metering counters every one hour. You can change this interval at the host level using the Set-VMHost cmdlet. The interval is specified in minutes and must be between 1 and 1440 (24 hours).
Set-VMHost -ResourceMeteringEnabled $true
To verify the current resource metering settings on the host:
Get-VMHost | Select-Object Name, ResourceMeteringEnabled
Step 5: Reset Resource Metering Counters
At the end of a billing period or reporting cycle, you will typically want to reset the counters so the next collection period starts fresh. Resetting does not disable metering; it simply zeroes out the accumulated totals and restarts the measurement duration timer.
Reset-VMResourceMetering -VMName "WebServer01"
To reset metering for all VMs simultaneously:
Get-VM | Reset-VMResourceMetering
Step 6: Disable Resource Metering
If you no longer need to track resource consumption for a specific VM, disable metering to free up the small overhead associated with data collection:
Disable-VMResourceMetering -VMName "WebServer01"
Step 7: Building a Simple Chargeback Report
Resource metering data can be used to build a chargeback or showback report. The following script collects data from all VMs, calculates cost estimates based on simple rate cards, and exports a report.
$cpuRatePerMHz = 0.001
$ramRatePer100MB = 0.002
$diskRatePer1GB = 0.0005
$netRatePer1GB = 0.001
Get-VM | ForEach-Object {
$metrics = Measure-VM -VM $_
$cpuCost = $metrics.AvgCPU * $cpuRatePerMHz
$ramCost = ($metrics.AvgRAM / 100) * $ramRatePer100MB
$diskCost = ($metrics.TotalDisk / 1GB) * $diskRatePer1GB
$netCost = ($metrics.TotalNetwork / 1GB) * $netRatePer1GB
[PSCustomObject]@{
VMName = $metrics.VMName
AvgCPUMHz = $metrics.AvgCPU
AvgRAMMB = $metrics.AvgRAM
DiskGB = [math]::Round($metrics.TotalDisk / 1GB, 2)
NetGB = [math]::Round($metrics.TotalNetwork / 1GB, 2)
EstCost = [math]::Round($cpuCost + $ramCost + $diskCost + $netCost, 4)
}
} | Export-Csv -Path "C:ReportsChargeback.csv" -NoTypeInformation
Write-Host "Chargeback report saved."
Step 8: Automating Monthly Collection
To automate monthly data collection and reset, create a scheduled task that runs a collection script on the last day of each month, saves the data, and then resets the counters. Use the Windows Task Scheduler to configure the task, or create it via PowerShell:
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:ScriptsCollectMetering.ps1"
$trigger = New-ScheduledTaskTrigger -Monthly -DaysOfMonth 28 -At 11:00PM
Register-ScheduledTask -TaskName "MonthlyVMMetering" -Action $action -Trigger $trigger -RunLevel Highest
Best Practices
Enable resource metering on all VMs from the moment they are provisioned so that you never miss a billing period. Always query and export data before resetting counters, as the reset is irreversible. Store exported CSVs in a network share or database for long-term trend analysis. Combine resource metering data with uptime data from event logs or System Center to build comprehensive SLA and capacity reports. Be aware that resource metering adds a small but non-zero overhead; in very high-density environments, consider the aggregate impact across hundreds of VMs.
Hyper-V Resource Metering is a lightweight, agentless way to gain visibility into virtual machine resource consumption on Windows Server 2016. Combined with PowerShell automation, it provides a solid foundation for cost allocation, capacity planning, and operational reporting in both private and hosted cloud environments.