How to Set Up Hyper-V Resource Metering on Windows Server 2019

Hyper-V Resource Metering is a feature in Windows Server 2019 that allows administrators to track and measure the resource consumption of virtual machines. This capability is essential for billing in hosted environments, capacity planning, and chargeback reporting. Resource metering collects data on CPU usage, memory consumption, network traffic, and disk I/O for each virtual machine over time.

Prerequisites

Before configuring resource metering, ensure that the Hyper-V role is installed on your Windows Server 2019 host. You must have administrative privileges on the Hyper-V host. The virtual machines you want to meter can be in any state — running, stopped, or saved — when you enable metering. PowerShell with the Hyper-V module is the primary tool used for resource metering configuration.

Understanding What Resource Metering Tracks

Hyper-V Resource Metering collects the following data points for each virtual machine. Average CPU usage is measured in megahertz (MHz) averaged over the metering interval. Minimum and maximum memory usage in megabytes captures the memory pressure on the VM. Network traffic is measured in megabytes for both incoming and outgoing traffic per network adapter. Storage allocation tracks the total disk space allocated to the VM across all virtual hard disks.

The metering data accumulates from the point at which metering is enabled. The data is stored in memory on the Hyper-V host and is reset when you call the reset cmdlet or when the host restarts. For persistent billing, you should query and save metering data at regular intervals using a scheduled task or monitoring script.

Enabling Resource Metering with PowerShell

To enable resource metering for a specific virtual machine, open an elevated PowerShell session on the Hyper-V host and run the Enable-VMResourceMetering cmdlet. Replace “WebServer01” with the name of your target VM.

Enable-VMResourceMetering -VMName "WebServer01"

To enable resource metering on all virtual machines on the host at once, use the Get-VM cmdlet piped to Enable-VMResourceMetering.

Get-VM | Enable-VMResourceMetering

To verify which virtual machines have resource metering enabled, query the ResourceMeteringEnabled property.

Get-VM | Select-Object Name, ResourceMeteringEnabled

Collecting Resource Metering Data

Once metering is enabled and time has passed, you can collect the accumulated data using the Measure-VM cmdlet. This returns a VMResourceMeteringData object containing all the collected metrics.

Measure-VM -VMName "WebServer01"

The output will display properties such as AverageCPU (in MHz), AverageRAM (in MB), MinimumRAM, MaximumRAM, TotalDisk (in MB), NetworkMeteredTrafficReport (broken down by adapter), and MeteringDuration showing how long data has been collected.

To export the metering data to a CSV file for further analysis or billing, pipe the output through Select-Object and Export-Csv.

Measure-VM -VMName "WebServer01" | Select-Object VMName, AverageCPU, AverageRAM, TotalDisk, MeteringDuration | Export-Csv -Path "C:ReportsWebServer01_Metering.csv" -NoTypeInformation

For collecting data from all VMs simultaneously and exporting a consolidated report, use the following approach.

Get-VM | Measure-VM | Select-Object VMName, AverageCPU, AverageRAM, MaximumRAM, TotalDisk, MeteringDuration | Export-Csv -Path "C:ReportsAll_VMs_Metering_$(Get-Date -Format 'yyyyMMdd').csv" -NoTypeInformation

Configuring Metering Intervals

By default, Hyper-V accumulates metering data continuously. You can set a resource pool to apply metering to groups of VMs and define accounting policies. The metering duration resets when you call Reset-VMResourceMetering. A typical billing workflow runs on a monthly cycle where the script queries, saves, then resets the counters.

# Export data before resetting
$date = Get-Date -Format "yyyyMM"
Get-VM | Measure-VM | Export-Csv -Path "C:BillingReport_$date.csv" -NoTypeInformation

# Reset all metering counters
Get-VM | Reset-VMResourceMetering

Write-Host "Metering data exported and counters reset for billing period $date"

Resetting Resource Metering Counters

Resetting metering counters clears the accumulated data and starts fresh collection. Use this at the start of each billing period. The Reset-VMResourceMetering cmdlet handles individual VMs or all VMs.

# Reset a single VM
Reset-VMResourceMetering -VMName "WebServer01"

# Reset all VMs
Get-VM | Reset-VMResourceMetering

Disabling Resource Metering

When you no longer need to track a VM’s resources, disable metering to free the associated overhead.

Disable-VMResourceMetering -VMName "WebServer01"

# Disable on all VMs
Get-VM | Disable-VMResourceMetering

Using Resource Pools with Metering

Hyper-V resource pools allow you to group virtual machines and apply metering at the pool level. This is useful for multi-tenant environments where you want to meter all VMs belonging to a specific customer together. Create a resource pool and assign VMs to it to enable pool-level metering.

# Create a new CPU resource pool
New-VMResourcePool -Name "CustomerA_Pool" -ResourcePoolType Processor

# Assign a VM's processor to the pool
Set-VMProcessor -VMName "WebServer01" -ResourcePoolName "CustomerA_Pool"

# Meter at the resource pool level
Measure-VMResourcePool -Name "CustomerA_Pool" -ResourcePoolType Processor

Automating Metering Data Collection with Scheduled Tasks

For production billing environments, automate data collection using Windows Task Scheduler. Create a PowerShell script that collects data at the end of each billing period and then resets counters.

# Save as C:ScriptsCollect-Metering.ps1

$ReportPath = "C:BillingReports"
$date = Get-Date -Format "yyyy-MM"
$OutputFile = Join-Path $ReportPath "Metering_$date.csv"

if (-not (Test-Path $ReportPath)) {
    New-Item -ItemType Directory -Path $ReportPath
}

Get-VM | Where-Object { $_.ResourceMeteringEnabled -eq $true } |
    Measure-VM |
    Select-Object VMName, AverageCPU, AverageRAM, MaximumRAM, MinimumRAM, TotalDisk, MeteringDuration |
    Export-Csv -Path $OutputFile -NoTypeInformation

Get-VM | Reset-VMResourceMetering
Write-EventLog -LogName Application -Source "Hyper-V Metering" -EventId 1001 -EntryType Information -Message "Metering data collected to $OutputFile"

Register this script as a scheduled task to run on the first day of each month at midnight.

$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NonInteractive -File C:ScriptsCollect-Metering.ps1"
$Trigger = New-ScheduledTaskTrigger -Monthly -DaysOfMonth 1 -At "00:00"
$Settings = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable $false
Register-ScheduledTask -TaskName "Hyper-V Metering Collect" -Action $Action -Trigger $Trigger -Settings $Settings -RunLevel Highest -User "SYSTEM"

Interpreting Metering Data

The AverageCPU value is reported in MHz, so a value of 800 on a host with 2.4 GHz processors means the VM used about 33% of a single logical CPU on average. AverageRAM reports the average working set in MB. TotalDisk shows the cumulative allocated storage, not actual used space. Network traffic is broken down in NetworkMeteredTrafficReport with Direction (Inbound/Outbound) and TotalTraffic in MB for each network adapter.

For capacity planning, trend the AverageCPU and MaximumRAM values over multiple months. A VM whose AverageCPU is consistently above 1500 MHz on a 2.4 GHz host is consuming more than 60% of a core on average and may need additional vCPUs. A VM whose MaximumRAM frequently equals its configured RAM limit is experiencing memory pressure and may need its allocation increased.

Conclusion

Hyper-V Resource Metering provides a lightweight, built-in mechanism to track VM resource consumption without requiring third-party monitoring tools. By combining PowerShell cmdlets with scheduled tasks and CSV exports, administrators can build automated billing and capacity planning workflows. Regular data collection, combined with resetting counters at billing period boundaries, gives accurate per-VM cost attribution essential for service providers and enterprise chargeback scenarios.