Start & stop perfmon collector set from powershell

I have been working quite much with perfmon lately, and have just started to explore Powershell the last few weeks. I just loving this language since this is pretty much similar to old school unix programming as we used at the University back in the early 90’s. Powershell offers a rich set of commands and libraries for accessing Windows server components.

In my case, I needed some commands to start and stop data collector sets in “Performance Monitor”. This code will use COM object Pla.DataCollectorSet to start and stop the collector set.

The first code piece will start the perfmon data collector set “SQLServer”.

$datacollectorset = New-Object -COM Pla.DataCollectorSet;
$datacollectorset.Query("SQLServer", $null);

…while the second code piece will stop the same data collector set.

$datacollectorset = New-Object -COM Pla.DataCollectorSet;
$datacollectorset.Query("SQLServer", $null);



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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s