This topic contains 4 replies, has 2 voices, and was last updated by
May 21, 2014 at 4:54 am #15450
On systems where I've implemented minimally privileged domain service accounts for SQL Server services I've run into a problem accessing perf counter data using the System.Diagnostics.PerformanceCounter object. If I run perfmon the counters all return valid results, and I get proper values from the OS counters (Pct Processor Used, Available Memory, etc.) through the PerformanceCounter object, but the SQL Server counters all return zero.
The service accounts are part of an AD group, and I've added that group to both the Performance Log Users and Performance Monitor Users groups in the local machine.
Any idea why this is happening? I've got scripts that have worked everywhere else, but this one client, and I'm not sure where to look to find it. (I've refreshed the counters – they work in perfmon.)
May 21, 2014 at 6:09 am #15458KeymasterPoints: 1,785Rank: Community Hero
I think you might get a better response from something like StackOverflow.com – only because this isn't PowerShell per se; you're dealing with the .NET Framework classes and it's more likely someone over there has done so.
I unfortunately don't know enough about how SQL works with those counters, although have you tried accessing them via WMI instead? I'm just wondering if that'd be any different. The fact that they work in PerfMon is vexing.
May 21, 2014 at 6:45 am #15461
Vexing is a good way to put it, Don. If I run PowerShell as Administrator, the counters return valid values as well, but my login is part of the local Admin group and returns 0, unless I run PowerShell as Administrator. I just don't know what security settings it requires to get valid values.
Thanks for responding.
May 21, 2014 at 9:00 am #15470
Apparently the same problem exists with the Get-Counter cmdlet. Here's a post on StackExchange identifying the problem: http://dba.stackexchange.com/questions/64898/powershell-get-counter-not-returning-values-for-sql-counters
May 21, 2014 at 3:17 pm #15489KeymasterPoints: 1,785Rank: Community Hero
It's likely a user privilege thing – there's an explicit privilege for being able to profile the system. Might be connected to that.
The topic ‘Diagnostics.PerformanceCounter Returns 0 for SQL Counters’ is closed to new replies.