1

The `Get-Counter '\Process(*)[process counter set]' cmdlet is slow.

  1. Is there a way to capture a stream of the output of the Get-Counter cmdlet and would that be faster?
  2. Can the Get-Counter cmdlet be run in a way that the output refreshes as fast as the same information gets refreshed in the Performance Monitor or Task Manager?

Examples:

Get-Counter '\Process(*)\ID Process' -EA SilentlyContinue | 
        Select -Expand CounterSamples | Select InstanceName, CookedValue
Get-Counter '\Process(*)\% Processor Time' -EA SilentlyContinue | 
        Select -Expand CounterSamples | Select CookedValue
Get-Counter '\Process(*)\Working Set - Private' -EA SilentlyContinue | 
        Select -Expand CounterSamples | Select CookedValue

1 Answer 1

2

The Get-Counter default "-SampleInterval" is already set to the minimum value of 1 second (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-counter?view=powershell-5.1).

So in answer to your first question, yes you can capture the output of each Get-Counter call to a log file with the Out-File command and then you can tail that log file. You will still be limited by the 1 second sample interval though.

Your second question is also limited by the 1 second sample interval, so no.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.