how to start stop perfmon PowerShell script

Saran 26 Reputation points
2021-10-15T16:55:20.717+00:00

how to start stop perfmon PowerShell script:

I have a data collector running, it is stopped sometimes, could be when OS reboots. Thinking to schedule scheduler job to start it if stopped only.

logman start "My DataCollectorSet"

Any suggestion or script pls.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 32,076 Reputation points
    2021-10-15T17:55:48.713+00:00

    You don't need a script. Just define a scheduled task with a trigger to "run at startup". Set it to execute logman.exe with the arguments "start mydatacollector". If the DC is already running, the start will just be ignored.

    If the data collector doesn't start because all services have not yet fully initialized, in the advanced settings of the trigger you can specify a delay time to give your server a little more time to initialize everything.

    What I used to do on my servers was to define a DC that collected basic cpu/memory/disk counters so if a user complained to me about performance at 3am, I could go back and check the counters. My DC was configured to use the system date and time in the file name. I wanted to have a .csv or .blg for every day. I defined a task to run at midnight which did a logman stop, followed by a logman start.

    The logman commands are the same in a .bat and .ps1 file.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Saran 26 Reputation points
    2021-10-16T02:28:25.963+00:00

    Thank you for you response and help.

    0 comments No comments