The instance name passed was not recognized as valid by a WMI data provider

1.7k Views Asked by At

I am trying to create one performance counter through "logman.exe" and try to read through Microsoft Tx (LINQ to Logs and Traces), but I am getting below error,

System.ComponentModel.Win32Exception: 'The instance name passed was not recognized as valid by a WMI data provider'

Process logman = Process.Start(
            "logman.exe",
            "create counter Test_Perf_log -c \"Processor(_Total)\"% Processor Time");
        logman.WaitForExit();

        IObservable<EtwNativeEvent> session = EtwObservable.FromSession("Test_Perf_log");
        using (session.Subscribe(e => Console.WriteLine("{0} {1}", e.TimeStamp, e.UserData)))
        {
            Console.ReadLine();
        }

I am suspecting that counter "Test_Perf_log" creation through "logman.exe" is not correct, please help on this.

Thanks,

1

There are 1 best solutions below

0
stuartd On BEST ANSWER

Your text is not correct: this is the output-

create counter Test_Perf_log -c "Processor(_Total)"% Processor Time

The format shown by logman /? is this:

create counter perf_log -c "\Processor(_Total)\% Processor Time"

To achieve that, you would use this:

"create counter perf_log -c \"\\Processor(_Total)\\% Processor Time\""