Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Get-Counter corrupts/disables PerfLib or returns invalid data #17147

Copy link
Copy link
@ExSport

Description

@ExSport
Issue body actions

Prerequisites

Steps to reproduce

When querying more counters at once and one of them is [User Input Delay Per Session] counterset, it fails with breaking the perfmon functionality (corrupted/disabled PerfLib, etc...).
It happens in some specific combinations like [User Input Delay Per Session] and [Memory] or [System] countersets. In such combinations invoking Get-Counter will terminate powershell process or returns non-zero Status property for the CounterSamples.
[User Input Delay Per Session] counterset works with .e.g. [SMB Server] counterset so not all are affected.
When two different get-counter cmdlets are invoked ([User Input Delay Per Session] separately), all counters are returned without issues.
Tested on Windows 2019, Powershell 5.1 and 7.2.2, same behavior.

Expected behavior

When querying array of counters in one "dataset" and [User Input Delay per Session] is used, valid data should be returned without needing to read [User Input Delay per Session] separately.
So this should work:

(Get-Counter -Counter @('\smb server\receive bytes/sec','\memory\page faults/sec','\user input delay per session(max)\max input delay') -SampleInterval 1 -MaxSamples 1).CounterSamples|Select InstanceName,Path,CookedValue,Status

Actual behavior

When querying array of counters in one dataset and [User Input Delay per Session] is used, it starts to return invalid data or terminates powershell completely.
Issuing command:

(Get-Counter -Counter @('\smb server\receive bytes/sec','\memory\page faults/sec','\user input delay per session(max)\max input delay') -SampleInterval 1 -MaxSamples 1).CounterSamples|Select InstanceName,Path,CookedValue,Status

Returns error and non-zero STATUS for MEMORY Counters:

Get-Counter: The data in one of the performance counter samples is not valid. View the Status property for each PerformanceCounterSample object to make sure it contains valid data.
InstanceName Path                                                         CookedValue     Status
------------ ----                                                         -----------     ------
             \\ov2p2194\smb server\receive bytes/sec                                0          0
             \\ov2p2194\memory\page faults/sec                                      0 3221228472
max          \\ov2p2194\user input delay per session(max)\max input delay           0          0

Error details

Exception             :
    Type    : System.Exception
    Message : The data in one of the performance counter samples is not valid. View the Status property for each
PerformanceCounterSample object to make sure it contains valid data.
    HResult : -2146233088
CategoryInfo          : InvalidResult: (:) [Get-Counter], Exception
FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
InvocationInfo        :
    MyCommand        : Get-Counter
    ScriptLineNumber : 1
    OffsetInLine     : 2
    HistoryId        : 36
    Line             : (Get-Counter -Counter @('\smb server\receive bytes/sec','\memory\page faults/sec','\user input
delay per session(max)\max input delay') -SampleInterval 1 -MaxSamples 1).CounterSamples|Select
InstanceName,Path,CookedValue,Status
    PositionMessage  : At line:1 char:2
                       + (Get-Counter -Counter @('\smb server\receive bytes/sec','\memory\page …
                       +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Get-Counter
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Screenshot 2022-04-13 164222

When [user input delay per session] removed, returned values are OK:
Screenshot 2022-04-13 165212

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.