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

When [user input delay per session] removed, returned values are OK:

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,StatusActual 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,StatusReturns error and non-zero STATUS for MEMORY Counters:
Error details
Environment data
Visuals
When [user input delay per session] removed, returned values are OK:
