How to quickly create Perfmons with PowerShell

Hi there,

if you need to quickly setup a perfmon, it is always fun to click it together. And its also fun to do this at scale šŸ˜‰ done this manually for 50 servers?… me neither!

Thats the reason why PowerShell is so awesome and should be used by everyone and for everything. šŸ™‚

Collect counters

First we need to get the counter names we want to capture. For this we can use the CmdLet “Get-Counter”

With this command we are searching for all counters with Processor* in their name. Just change the string and you can search for every counter you need.


To filter this a litte more we can get some information about the parent counters and if you need it a little bit more detailed counters also by each child counter



will get you a list of all parent counters

This one will give you a list of every single child counter in the setPerfMon_02-2

This way you can select your counters and put them into an array. I will explain later how that will work.

Get your first counter information from a local machine

Now we can start collecting some information from these counters.

We simply add all counters into a variable and let out Get-Counter CmdLet do the rest..


Whoa…whoa.. stop right here. That does not really help, does it? This fast running list is not really better than anything done manually in perfmon.

But you could simply pipe that into something elseĀ and siff through it afterwards. Which would be also as fun and productive as doing all this manually in perfmon.

Simply use our other friend “Export-Counters” and pipe it into a .blg file and have it done that way.

Now we can work with it. This command will run until the counterset has finished, in this case it will take 5*10= 50 secondsĀ (SampleIntervall * MaxSamples =Ā  Runtime)

Output file (ignore the “old” folder…it’s old)


and the view in Perfmon



Now we’ve coverd the basics with this, we can move over to do this at scale. By using PowerShell remoting.Ā Ā There areĀ only three things to considerĀ if you want to do this remotly (apart from having PowerShell remotingĀ working in your environment)

  1. All counters you want to measure are neededĀ on the destination machine. Otherwise you willĀ get a bunch of errors that the counter cannot be found on the machine. Simply get the counters of the remote machine beforehand on that machine or machinetype.
  2. If you run the folowing command on multiple servers at once, the data will be combined into one single .BLG file for all servers. If you need seperate date just run it in an Invoke-Command scriptblock as a job.
  3. make sure you don’t use the same filename for the .blg file or use the -Force option to overwrite it. Otherwise you will end up with no data! I’ve had oneĀ or two ‘doh moments with this one…

This command simply gets the counters from the remote VM “FreDSC01” and puts it into a new .blg file.



If you know which counters you want to collect you can put them into an array (as mentioned earlier).

This way you can choose your counterset and change it pretty easily.

If you need an inspiration which counters you need to go a little bit deeper with a little bit more automationĀ  for the evaluation in the end. You can also take a look at PAL.

Cheers Philipp

4 thoughts on “How to quickly create Perfmons with PowerShell

    1. thanks, i guess you could also do something with WMI to get some performance data as well. but normally you can get all needed data with the PowerShell basics I wrote about, just put all needed counters together. But Resource Manager is just an “at a glance tool” to see whats going on.

Leave a Reply

Your email address will not be published. Required fields are marked *