So I have created a script to gather counters using Get-CimInstance
(which supercedes Get-WMIObject
) and run it as a services via srvany.exe
.
I get an issue where for the .Net CLR classes, some processes are missing not gathered, especially one that I want to monitor: w3wp
.
When running the application in an elevated Powershell console, the command returns all processes relying on .Net, whereas if I run it in a standard powershell console, only the local .Net processes are gathered.
I need to set up the appropriate permissions to that service so that it gathers all the metrics of all processes. I have tried running the process as Administrator, a domain admin account, to no avail.
I've tried giving explicitly all the permissions on root\cimv2
to the Administrator in the wmimgmt.msc
WMI Admin console without solving the problem.
The default running context for services is SYSTEM, which is also the default running context for IIS.
I'm at a loss as to what permissions I need to give and where to allow this service to gather all the data. I feel that starting it as a service logging in as the admin account should be enough but apparently not.
Example of the issue in
PS C:\Users\user> gcim Win32_PerfFormattedData_NETFramework_NETCLRSecurity | select-object Name
Name
----
_Global_
powershell
SCNotification
And now in a Run As Administrator powershell console:
PS C:\WINDOWS\system32> gcim Win32_PerfFormattedData_NETFramework_NETCLRSecurity | select-object Name
Name
----
_Global_
powershell
w3wp
w3wp#1
w3wp#2
powershell#1
SCNotification
SCNotification#1
Using the alternative Get-Counter
in an non-admin console is even worse:
PS C:\Users\user> Get-Counter -Counter "\.NET CLR Memory(*)\*" -SampleInterval 1 -MaxSamples 1
Get-Counter : The specified object was not found on the computer.
At line:1 char:1
+ Get-Counter -Counter "\.NET CLR Memory(*)\*" -SampleInterval 1 -MaxSamples 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Get-Counter], Exception
+ FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommand
Whereas it gives the right information ran in an admin console.
0 Answers