【问题标题】:Retrieve Performance Counter's "Explain Text"检索性能计数器的“说明文本”
【发布时间】:2014-02-03 09:42:30
【问题描述】:

如何通过 Powershell 获取性能计数器 Explain Text 的字符串值。

我认为这将是计数器的属性

Get-Counter -Counter "\Processor(_Total)\% Processor Time"|gm

(Get-Counter '\logicalDisk(*)\Avg. Disk Queue Length').countersamples|gm

但事实并非如此。我找到Lodctr /q 查询计数器和this。但是,我找不到确切的获取字符串值的方法。

【问题讨论】:

    标签: powershell powershell-3.0 performancecounter query-performance


    【解决方案1】:

    如果您可以调用 .net 框架对象,您可以访问PerformanceCounterCategory 提供的所有方法。

    以下内容应该可以帮助您入门:

    $categoryName = "Processor"
    $categoryInstance = "_Total"
    $counterName = "% Processor Time"
    
    # Call the static method to get the Help for the category
    $categoryHelp = [System.Diagnostics.PerformanceCounterCategory]::GetCategories() | ?{$_.CategoryName -like $categoryName} | select -expandproperty  CategoryHelp
    
    # Create an instance so that GetCounters() can be called
    $pcc = new-object System.Diagnostics.PerformanceCounterCategory($categoryName)
    $counterHelp = $pcc.GetCounters($categoryInstance) | ?{$_.CounterName -like $counterName} | select -expandproperty CounterHelp
    
    $categoryHelp 
    $counterHelp 
    

    【讨论】:

      猜你喜欢
      • 2010-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      • 2012-11-16
      相关资源
      最近更新 更多