Use Performance Monitor to get VM performance statistics

PowerShell logoIn PowerCLI you can use the Get-Stat cmdlet to get performance statistics. But for Microsoft Windows virtual machines with the VMware Tools installed there is another way to get the statistics. Even without using PowerCLI.

Performance Monitor

The VMware Tools for a Microsoft Windows computer adds VMware specific counters to the Performance Monitor. The counters are in two categories: “VM Memory” and “VM Processor”. These categories contain the following counters (vSphere 4.1):

VM Memory

  • Memory Active in MB
  • Memory Ballooned in MB
  • Memory Limit in MB
  • Memory Mapped in MB
  • Memory Overhead in MB
  • Memory Reservation in MB
  • Memory Shared in MB
  • Memory Shared Saved in MB
  • Memory Shares
  • Memory Swapped in MB
  • Memory Target Size
  • Memory Used in MB

VM Processor

  • % Processor Time
  • CPU stolen time
  • Effective VM Speed in MHz
  • Host processor speed in MHz
  • Limit in MHz
  • Reservation in MHz
  • Shares

In figure 1 you see some of the VMware counters in the Performance Monitor Add Counters window.

Figure 1. Performance Monitor Add Counters window.

After adding these counters you can see them in action in figure 2.

Figure 2. Performance Monitor VMware counters in action.

The PowerShell Get-Counter cmdlet

The PowerShell Get-Counter cmdlet gets performance counter data from local and remote computers. The PowerShell script of listing 1 shows all the VMware performance counters for a server.

$ComputerName = "server01"
Get-Counter -ComputerName $ComputerName -ListSet VM* |
Select-Object -Expandproperty Counter

Listing 1. PowerShell script to get all VMware counters for server Server01.

Sample output of this script is shown in output 1.

\\server01\VM Processor(*)\Limit in MHz
\\server01\VM Processor(*)\Reservation in MHz
\\server01\VM Processor(*)\Shares
\\server01\VM Processor(*)\CPU stolen time
\\server01\VM Processor(*)\% Processor Time
\\server01\VM Processor(*)\Effective VM Speed in MHz
\\server01\VM Processor(*)\Host processor speed in MHz
\\server01\VM Memory\Memory Active in MB
\\server01\VM Memory\Memory Ballooned in MB
\\server01\VM Memory\Memory Limit in MB
\\server01\VM Memory\Memory Mapped in MB
\\server01\VM Memory\Memory Overhead in MB
\\server01\VM Memory\Memory Reservation in MB
\\server01\VM Memory\Memory Shared in MB
\\server01\VM Memory\Memory Shared Saved in MB
\\server01\VM Memory\Memory Shares
\\server01\VM Memory\Memory Swapped in MB
\\server01\VM Memory\Memory Target Size
\\server01\VM Memory\Memory Used in MB

Output 1. Sample output of the script of listing 1.

The PowerShell script of listing 2 will list not only the VMware counters, but it will list all the Performance Monitor counters for server Server01.

$ComputerName = "server01"
Get-Counter -ComputerName $ComputerName -ListSet * |
Select -Expandproperty Counter

Listing 2. PowerShell script to get all Performance Monitor counters for server Server01.

The PowerShell script of listing 3 gets all VMware counters for server Server01, and retrieves the counter values, ten times with a two second interval. A sample output of this script for one interval is shown in output 2.

$ComputerName = "Server01"
Get-Counter -ComputerName $ComputerName -ListSet VM* |
  Get-Counter -MaxSamples 10 -SampleInterval 2

Listing 3. PowerShell script to get all VMware counter values for server Server01.


Line 2: Get all the VMware counters.

Line 3: Get the values for all the VMware counters, 10 times with a 2 seconds interval.

Output 2 shows the output of the script of listing 3 for one interval.

Timestamp                 CounterSamples
---------                 --------------
2012-06-19 18:11:20       \\server01\vm processor(_total)\limit in mhz :

                          \\server01\vm processor(_total)\reservation in mhz :

                          \\server01\vm processor(_total)\shares :

                          \\server01\vm processor(_total)\cpu stolen time :

                          \\server01\vm processor(_total)\% processor time :

                          \\server01\vm processor(_total)\effective vm speed in mhz :

                          \\server01\vm processor(_total)\host processor speed in mhz :

                          \\server01\vm memory\memory active in mb :

                          \\server01\vm memory\memory ballooned in mb :

                          \\server01\vm memory\memory limit in mb :

                          \\server01\vm memory\memory mapped in mb :

                          \\server01\vm memory\memory overhead in mb :

                          \\server01\vm memory\memory reservation in mb :

                          \\server01\vm memory\memory shared in mb :

                          \\server01\vm memory\memory shared saved in mb :

                          \\server01\vm memory\memory shares :

                          \\server01\vm memory\memory swapped in mb :

                          \\server01\vm memory\memory target size :

                          \\server01\vm memory\memory used in mb :

Output 2. Sample output of the script of listing 3 for one interval.

Export the output to a .csv file

You can use the PowerShell Export-Counter cmdlet to export performance counter data to log files in binary performance log (.blg), comma-separated value (.csv), or tab-separated value (.tsv) format.

Listing 4 shows you how to use the Export-Counter cmdlet to export to a .csv file. You can use this .csv file for further analysis of the counters in a spreadsheet. Or to import them in another PowerShell script.

$ComputerName = "server01"
$Path = "vSphereCounters.csv"
Get-Counter -ComputerName $ComputerName -ListSet VM* |
  Get-Counter -MaxSamples 10 -SampleInterval 2 |
  Export-Counter -Path $Path -FileFormat Csv -Force 

Listing 4. PowerShell script to get all VMware counters for server Server01 and export them to vSphereCounters.csv.

When you open the vSphereCounters.csv file in Excel, the output will look like output 3. Every counter has its own column.

Output of the Export-Counter cmdlet imported in Excel
Output 3. Output of the Export-Counter cmdlet imported in Excel.


The VMware Tools adds performance counters to the Windows Performance Monitor. You can use The PowerShell Get-Counter and Export-Counter cmdlets to retrieve the counter values.


About Robert van den Nieuwendijk
Robert van den Nieuwendijk is a freelance senior systems engineer with over 30 years of experience in the IT industry. He focusses on VMware vCloud Suite and Microsoft Windows Server. He tries to automate as much of his work as possible using Microsoft PowerShell. Robert is the author of the books “Learning PowerCLI” and “Learning PowerCLI – Second Edition.” Robert is a frequent contributor and moderator at the VMware VMTN Communities. He has a bachelor degree in software engineering and holds the following IT certifications and accreditations: VSP 2016, VTSP 2016, VCP4-DCV, VCP5-DCV, VCP6-DCV, VCP6-CMA, VCA-Cloud, VCA-WM, VCA-NV, VMSP, VMTSP, ZCS, ZCP, ZCP-Cloud, MCSE, MCSA, MCP, MCP+I, PRINCE2 Foundation and ITIL Foundation. In 2012, 2013, 2014, 2015, 2016, 2017, 2018 and 2019 Robert received the VMware vExpert award for his contribution to the community of VMware users over the past year. In 2017 Robert also received the VMware vExpert Cloud award. PernixData made him in 2015 a member of the PernixPro.

5 Responses to Use Performance Monitor to get VM performance statistics

  1. Rodney Fisher says:

    HI Robert

    Very interesting article, helps quite a bit. I tried monitoring the VM Processor(_total)\CPU Stolen time via the Perf Mon and no data arrived. Your article provided a way to test that the counters are actually working on the server but that Perf Mon is not working with these additional counters on 1 of 6 servers I have to solve an issue with. I added them into Perf Mon but there is nothing in the .blg file after I stop the collection. Seems even more odd now as the Powershell does. Must be something with the Perf Mon on this server as another server seems to work. Maybe a bug.

    I was wondering if you have any information about the very small numbers returned by this counter and how one should interpret them. I have collected some other metrics on the server and at times the CPU Queue Length grows a bit, sometimes quite periodically….

    Great article….

  2. Hi Rodney,

    I am glad that you like my article. And I am sorry that it took me so long to respond.

    According to “Timekeeping in VMware Virtual machines” ( CPU Stolen Time is “time when the guest operating system was ready to run, but the virtual machine was descheduled by the host scheduler”. So IMHO this means small numbers are better than large numbers.

  3. kennethgknight says:

    Why is my VM processor time so much higher than my normal processor time on perfmon? this is a Vmware VM which one should i be looking at if i’m looking for trouble areas?

  4. Don says:

    Thanks … can you also write some article on vm performance in general ? This topic is so vast & so many script are there which cover mainly cpu/ram & ready.. but then disk io & network io etc is not covered & get-esxtop is so complex too .. so a consolidated script will help thanks

  5. Pingback: VMWare VMotion causing performance to increase?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: