JBurace
JBurace

Reputation: 5633

Get-Counter: negative denominator?

I am running this Powershell command:

Get-counter -Counter "\Processor(_Total)\% Processor Time" –Continuous

Which I found on http://technet.microsoft.com/en-us/magazine/ee872428.aspx

I am using it to monitor the CPU, but about a minute after running it this error occurred (which causes it to halt):

Get-Counter : A counter with a negative denominator value was detected.
At line:1 char:12
+ Get-counter <<<<  -Counter "\Processor(_Total)\% Processor Time" -Continuous
    + CategoryInfo          : InvalidResult: (:) [Get-Counter], Exception
    + FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand

What caused this to occur? What can I do to prevent this, so the command doesn't abort like so (like suppressing errors)?

I'm unable to reproduce this on a regular basis though.

Upvotes: 2

Views: 1366

Answers (1)

justinf
justinf

Reputation: 1298

It would seem other people have the same issue if your code looks like the examples in this link . It might be a problem with your environment though. Does this happen on every pc you own ?

The powershell guys also seems to have some info that should help you sort this out Powershell guy's blog. He basically just adds this command -EA silentlycontinue and imports the counter.

Upvotes: 1

Related Questions