0

Im using Windows10, i need to check CPU usage and memory usage for a power shell script which is scheduled to run every 3mins. I have created a data collector set with following details

I use perfmon, to monitor CPU Usage i have added:

  • \process(Powershell_12345)%ProcessorTime

to monitor memory usage i have added:

  • \Memory%Committed bytes in Use
  • \Memory%Committed bytes

But problem is every time powershell script gets triggered through scheduler a new PID is created and the process has names concatenated with PID like powershell_ If i add the powershell process only till that thread is used, it would get monitored and not for entire day

How do i use perfmon to monitor powershell.exe for a day ?

Yerigeri
  • 1
  • 2

1 Answers1

0

This should probably be on SF rather than SO but the easiest way to do this is going to just be to monitor All process instances and then go back and grab the powershell instance when you look through the data later. Other option would be to programmatically create the data collector set as the first step in your script, more info on that Here A lot more work but you'll end up with cleaner data so it just depends what's important to you.

A final option if you'd like to avoid using perfmon at all is to take a look at This Function I created for my blog about a year ago, in all of my testing it's results correlate to those seen in perfmon quite well, if your interested in going that way let me know and I can show you how to set it up as a job and have it keep running in a loop while your script runs to generate the data you are looking for.

Mike Garuccio
  • 2,588
  • 1
  • 11
  • 20