所以我创build了一个脚本来使用Get-CimInstance (它取代了Get-WMIObject )来收集计数器,并通过srvany.exe作为服务来运行它。
我遇到一个问题,在.net CLR类中,有些进程没有收集,特别是我想要监视的进程: w3wp 。 在提升的Powershell控制台中运行应用程序时,该命令将返回依赖.Net的所有进程,而如果我在标准的PowerShell控制台中运行它,则只会收集本地.Net进程。
我需要为该服务设置适当的权限,以便收集所有进程的所有度量标准。 我已经尝试以pipe理员身份运行该进程,域pipe理员帐户,无济于事。 我已经尝试在wmimgmt.msc WMIpipe理控制台上明确给出root\cimv2上的所有权限,而不解决问题。
服务的默认运行上下文是SYSTEM,这也是IIS的默认运行上下文。
我不知道需要给予什么权限以及在哪里允许此服务收集所有数据。 我觉得作为一个服务login作为pipe理员帐户应该是足够的,但显然不是。
在这个问题的例子
PS C:\Users\user> gcim Win32_PerfFormattedData_NETFramework_NETCLRSecurity | select-object Name Name ---- _Global_ powershell SCNotification
现在,以“以pipe理员身份运行”的PowerShell控制台:
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
在非pipe理控制台中使用替代的Get-Counter更糟糕:
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
而它可以在pipe理控制台中运行正确的信息。