Speedup Perfmon Setup for Multiple Counters and Computers

Starting perfmon and adding each counter one by one for each computer that you want to monitor can be a bit painful. For instance, this morning I wanted to check about 10 counters for RDP/RemoteFX on each of the active VDI computers (28 VMs) in a collection.  That would have taken a lot of time to set that up. I then decided to build a small PowerShell function to help setting up common Perfmon counters on one or more computers.


Example on how to use it :

Import-Module .\libWindowsPerformance.psm1 -Force

Get-PerformanceMonitoring -computers WIN10000,WIN10001 -templates Core_Windows,Core_SQLServer


This will pop a perfmon window with the counters as specified in the template file Core_Windows and Core_SQLServer for each of the servers specified. From there, you can simply switch to the real-time view by clicking this button:




Note that not all the counter instances are visible by default. You can add the missing counters in the same way as before, through Add Counters. The dialog box will only show the counters that were selected in the template.

I’ve already started to create the following templates:



Let me know if you have ideas on how to enrich those templates or simply would like to see new ones! To create new templates, simply create a text file in \PerformanceCountersTemplates and include the counters that you want. Note that you can specify multiple templates in one call,  they will be merged at runtime.


You can also use the function to persist the counters selected to a log file by using the following form:


Get-PerformanceMonitoring -computers WIN10000,WIN10001 -templates Core_Windows,Core_SQLServer -persistPerformanceData

Function Get-PerformanceMonitoring($computers,$templates,[switch]$persistPerformanceData)
    foreach($template in $templates)
        $counters+=Get-Content .\PerformanceCountersTemplates\$template.txt
        Get-Counter -ComputerName $computers -Counter $counters -Continuous | Export-Counter -Path PerfmonData\$executionTime`_Capture.blg -Force
        Get-Counter -ComputerName $computers -Counter $counters -MaxSamples 2 | Export-Counter -Path PerfmonData\$executionTime`_Capture.blg -Force
        Start-Process c:\code\Windows\PerfmonData\$executionTime`_Capture.blg

This will be added to http://gemautomation.codeplex.com as part of libWindowsPerformance.psm1 in the next commit.


Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s