Hyper-V Performance Monitor Tool

* Update: Added Azure Stack support *
* Update: Added Hyper-V Container support * 


Blog Post
 : A tool is born
Video : Remote monitoring Nano Hyper-V Server using on Windows 10 running Hyper-V.

Hyper-V Performance Monitor Tool written in PowerShell allows you to gather and view VM performance statistics as seen from inside the Guest on every discovered or manually added Hyper-V host. Configure the number of samples to take and the interval between them, choose your Hyper-V hosts and hit the 'Monitor' button. GUI is used by default, all performance statistics averages are presented in GridView. Specify the '-PSobjects' parameter to skip the GUI and return output in the console instead. See screenshots below with output from GridView and the console.

.\Monitor-HyperVGuestPerformance.ps1

### export data to csv via GUI, defaults to current dir
.\Monitor-HyperVGuestPerformance.ps1 -ExportToCsv 

### retrieve data as PSobjects, great for parsing and logging, -name parameter is optional, defaults to automatic discovery
.\Monitor-HyperVGuestPerformance.ps1 -PSobjects

### specify host and interval/samples manually
.\Monitor-HyperVGuestPerformance.ps1  -Name host1,host2 -PSobjects -Interval 2 -MaxSamples 5

### accepts pipeline input
'Host1','Host2' 
 | .\Monitor-HyperVGuestPerformance.ps1 -PSobjects 

 ### Log to SQL server with Write-ObjectToSQL , this example uses SQL auth
.\Monitor-HyperVGuestPerformance.ps1 –PSobjects  |  Write-ObjectToSQL –TableName table –Database db -Server server –credential (get-credential)

- PowerShell V3+
- ISE Out-Gridview support (not required with -PSobjects)
- Valid pass-through credentials when executed from remote machine (Get-Counter limitation) 
- WMI DCOM network access (Get-WMIObject)
- One or more Hyper-V hosts

- Discovers Hosts from AD, Cluster or locally
- Manually add hosts when they can't be discovered automatically
- Retrieves Hyper-V host configuration through WMI
- Easy to use GUI  
- Invokes Get-Counter for each Hyper-V host simultaneously
- Parallel processing by creating a runspace for each Hyper-V host
- Matches and indexes guest performance samples against Hyper-V WMI virtualization data from host
- Combines and adds up all data (CPU/Mem/NIC interfaces/Disks KB-IOPS-Queue) for each VM
- Displays Volume and 'VM's' _Totals on top
- Export to Csv, provide '-ExportToCsv' parameter to the script
- Shows Performance Data as seen from inside the Guest (task manager)
- No performance impact whatsoever, remote 'get-counter' is used against the Hyper-V Host 
- Compatible and tested with Hyper-V running on Windows 10 and Nano server!

- [17-11-2015] Added Name parameter and pipeline support for adding one or more hosts manually (requested in Q/A) 
- [17-11-2015] Changed AD search from domain DC to domain GC (requested in Q/A) 
- [28-11-2015] Added Windows Server 2016 TP and SMB location support  
- [29-11-2015] Added Export to CSV (-ExportToCsv) 
- [07-12-2015] Refactored location samples: multiple locations per VM, totals for all locations (SMB/LocalDisk/CSV)
- [09-12-2015] Added deselect/select all button
- [15-12-2015] Constructed parameter sets and detailed help functionality
- [15-12-2015] Added error host connection/access handling, finetuned script code again and placed comments
- [20-12-2015] Added 'Add host' functionality in GUI, enriched form with comments and nicer layout
- [05-01-2016] Fixed issues with counters on Windows 10. VM's running on Windows 10 with Hyper-V are now supported!
- [08-01-2016] Also added IOPS read/write and disk queue length as requested in Q/A! 
- [09-06-2016] MAS support, translates VM Guid to VM name, shows Resourcegroup,SubscriptionID and Region.
- [09-06-2016] Fixed a issue where remote Azure Stack hosts could not be queried correctly.
- [26-10-2016] Hyper-V Container support! Disk are now associated with the container and the individual containers are identified.

- Battle hardened Performance Testing
- _Total per Hyper-V server (alternative atm is to select one Hyper-V server and read out the '_Total (_VMs)'
- 'Hyper-V Containers' support, new container virtualization namespace classes (low prio atm, vote for it in QA) 
- Add support for Azure Stack VM Guid to Name 
- Optimize ADSI GC query performance with over 100 computer accounts in AD.

Monitor and view realtime Hyper-V VM (Guest) Performance on your Hyper-V hosts. This free tool monitors CPU, Memory, Disk I/O and Network statistics as seen from inside the guest. All monitoring data is retrieved via WMI only, AD Hyper-V Host discovery via traditional ADSI, no modules or software required, run from any member server.

After collecting all host information the scripts 'Get-VMGuestSamples' function opens up a PowerShell runspace pool and creates a local runspace job executing the 'Get-Counter' cmdlet for each Hyper-V host found. Finally a gridview report will be presented with an overview of all VM's and associated resource metrics plus '_totals' for all VM's and disk resource locationss combined. Each metric represents performance data from inside the guest itself, CPU is the actual average of the total percentage CPU usage used in the VM. The same applies for the Disk I/O and Nic (sent/received) metrics which are representing the total sum of all disks/interfaces combined for each VM. Specify the '-ExportToCsv' parameter to export the data to file or the '-PSobjects' parameter to return data as objects (skipping the GUI) for all your filtering and logging needs.

As far as I'm aware there is no other PowerShell script/tool out there that does the same so I'm really committed to fix every bug and add functionality along the way. Please supply feedback in the Q/A section of this contribution, just letting me know that it works is also much appreciated. I really want to know if it works for you.

Gridview Output (default)

Hyper-V VM Performance Gridview output with GUI

File Copy over Network from one VM to another

Hyper-V VM Performance file copy over network

With updated disk IOPS and queue length counters

IOPS and Disk Queue Lenght output Hyper-V VM Performance Tool

Using -PSobjects with PS filtering and sort on VM's hitting more then 50% CPU in the Guest OS

PSobjects output, great for logging, filtering and parsing with Hyper-V VM Performance Tool.

Using -PSobjects using -Interval and -MaxSamples, filter on DiskRead -gt 1000 Kb and filter the'_Total's' out

 PSobjects output with intervan and samples plus a filter where CPU is greater then 10 with Hyper-V Performance Monitor Tool.

 

You could also use 'measure-vm' for measuring metrics for the virtual machine. It's incorperated in the Hyper-V module to get metering and utilization of the VM from outside the guest VM for billing or resource consumption purposes.  The difference between 'measure-vm' and this tool is as follows.

  

Hyper-V VM PerfMon Tool 

Measure-VM 

Purpose

Performance Statistics

Resource Metering

Scenario

Performance Troubleshooting /Reporting/Monitoring

Chargeback/Billing

Method

Guest Counter Samples (inside VM)

Hyper-V host information (outside VM)

CPU

Avg Percentage

Total MegaHertz

Memory

Avg Configured, Avg used in VM (MB)

Average,maximum, minimum used (MB)

Disk

Avg Read/Write (KB and IOPS), Disk Queue Length

Total allocation in MB, harddiskmetrics (avg latency, aggregatedAverageIOPS, total dataRead, total datawritten)

Nic

Avg Sent/Received (KB)

Total Sent/Receive (MB)

Click here for more information about Measure-VM or read this great post from Didier van Hoye (WorkingHardInIT)

PowerShell
Edit|Remove
#requires -Version 3 
<# 
 
        .NOTES   
 
        File Name      : Monitor-HyperVGuestPerformance.ps1   
        Version        : 0.95 
        Author         : Ruud Borst - ruud@ruudborst.nl 
        Reviewer    : Darryl van der Peijl - darrylvanderpeijl@outlook.com 
        Requires       : PowerShell V3+ 
 
        .LINK   
 
        http://www.ruudborst.nl 
         
        .LINK   
 
        https://gallery.technet.microsoft.com/Show-Hyper-V-Virtual-652fdd54 
     
        .SYNOPSIS 
 
        This GUI based Hyper-V VM Guest Performance monitoring tool collects, processes VM Guest Performance Statistics over a specified period of time from discovered or specified Hyper-V hosts. 
 
        .DESCRIPTION 
 
        Retrieve, show or export realtime Hyper-V Guest VM Performance Statistics. This GUI-based tool retrieves cpu,memory,disk i/o and network statistiscs from inside the guest.  
        All information is retrieved via WMI and ADSI, no modules required, run on any domain or cluster joined server. 
        After collecting all host information the script opens up a PowerShell runspacepool and creates a local runspace job executing 'get-counter' for each Hyper-V host found. 
        Finally a gridview output will be presented with a overview of all VM's and associated counters plus all _totals on the platform.  
        Each counter counter represents performance data from inside the guest itself, CPU is the actual total CPU usage in the VM.  
        The same applies for the disk and network values they are representing the total sum of all disks/interfaces combined.  
        Specify the '-ExportToCsv' parameter for exporting the statistics to file and -PSobjects for returning all objects in the console for further processing. 
 
        All information is retrieved via WMI, ADSI is used for global catalog queries. No modules required whatsoever, script can be executed on any domain or cluster joined member server. 
 
        .PARAMETER Name 
         Enter one or more Hyper-V Hosts to collect VM Guest Performance Statistics from, used with '-PSobjects' parameter.  
         
        .PARAMETER ExportToCsv 
         Supply this switch parameter without value for exporting the data to CSV instead. 
         
        .PARAMETER ExportToCSVPath 
         Enter the directory path to export the CSV file in, defaults to current directory. 
         
        .PARAMETER PSobjects 
         Use this parameter to return PSobjects as output instead, GUI is not used so '-Name' parameter is required to enter the Hyper-V hosts manually. 
         
        .PARAMETER MaxSamples 
         Enter the number of samples to take, defaults to 1.  
        
        .PARAMETER Interval 
         Enter the interval to wait between the samples, defaults to 1. 
 
        .EXAMPLE  
         .\Monitor-HyperVGuestPerformance.ps1 
         Runs GUI by default with configurable samples, interval and select or add Hyper-V Hosts. 
 
         .EXAMPLE  
         .\Monitor-HyperVGuestPerformance.ps1 -PSobjects 
         Returns PSobjects as output instead of running the GUI.  
         Great for parsing and logging, -name parameter is optional, defaults to automatic discovery of hosts. 
 
        .EXAMPLE  
         .\Monitor-HyperVGuestPerformance.ps1 -Interval 2 -MaxSamples 5 -PSobjects 
         The '-Interval' and '-Maxsamples' parameters are optional and default to 1 when not specified. 
          
        .EXAMPLE  
         .\Monitor-HyperVGuestPerformance.ps1  -Name Host1,Host2 -PSobjects 
         Specify Hyper-V hosts manually instead of the deault automatic discovery of hosts. 
 
         .EXAMPLE  
         'Host1','Host2' | .\Monitor-HyperVGuestPerformance.ps1 -PSobjects 
         Script accepts pipeline input, input is processed as the name parameter. 
 
        .EXAMPLE  
         Monitor-HyperVGuestPerformance.ps1 -ExportToCsv -ExportToCSVPath 'd:\export' 
         Export results to CSV when clicking 'Collect' in the GUI instead of displaying the results in 'Out-GridView'. 
         The '-ExportToCSVPath' is optional and defaults to current working directory when not specified. 
 
#>
 
 

Monitor and view real-time Hyper-V VM Guest Performance on your Hyper-V hosts. This free Tool (GUI) monitors CPU, Memory, Disk I/O and Network statistics as seen from inside the guest. All monitoring data is retrieved via WMI only, AD discovery via traditional ADSI, no modules or software required, run from any member server.

After collecting all host information the script opens up a PowerShell runspace pool and creates a local runspace job executing 'get-counter' for each Hyper-V host found. Finally by default a gridview output will be presented with a overview of all VM's and associated counters plus all _totals on the platform. Each counter represents performance data from inside the guest itself, CPU is the actual total CPU usage in the VM. The same applies for the IO/Nic(sent/received) which are representing the total sum of all disks/interfaces combined. Specify the '-ExportToCsv' parameter for exporting the statistics to file, by default data is displayed in GridView.

As far as I'm aware there is no other PowerShell tool out there that does the same so I'm really committed to fix every bug and add functionality along the way. Please supply feedback in the Q/A section of this contribution.