Script to query perfmon (.blg) files

I have written a basic script to query the daily performance logs on an Exchange 2013 server. Download below from TechNet gallery

It works fine for “standard” performance counters, but it does not work for counters with an * in them. Example \Server\MSExchangeIS Store(*)\RPC Average Latency.

The problem is that “\Server\MSExchangeIS Store(*)\RPC Average Latency” is not actually a counter that exists on the server, it is a list set of counters. When you add that counter in perfmon, it adds one counter for each store on the server.

I can expand the list set via Get-Counter -ListSet “MSExchange IS Store”, then find the actual counter I want in the output and put that into the script, but I would like to get it working by just putting “MSExchangeIS Store(*)\RPC Average Latency” into the script and getting output for each Store on the server.

Does that make sense?

Anyone have any ideas on how I can get that working?

It looks lke Import-Counter also has a -ListSet parameter. Your script could run that command against the blg files, then compare your $Counter parameter (using wildcards to the list) before running Import-Counter again with the matching values. Something like this, though I haven’t tested it:

$counterList = @(Import-Counter -ListSet $env:exchangeinstallpath\Logging\Diagnostics\DailyPerformanceLogs\*.blg)
$counterList = $counterList -like "\\$Server\$Counter"
$Data = Import-Counter -Path $env:exchangeinstallpath\Logging\Diagnostics\DailyPerformanceLogs\*.blg -Counter $counterList