Powershell 检索性能计数器';s";“解释文本”;

Powershell 检索性能计数器';s";“解释文本”;,powershell,powershell-3.0,performancecounter,query-performance,Powershell,Powershell 3.0,Performancecounter,Query Performance,如何通过Powershell获取性能计数器的解释文本字符串值 我以为这是柜台的财产 Get Counter-Counter“\Processor(\u Total)\%Processor Time”\gm (获取计数器'\logicalDisk(*)\Avg.磁盘队列长度')。计数器采样| gm 但事实并非如此。我发现要查询计数器和。但是,我找不到确切的获取字符串值的方法。如果您可以调用.net framework对象,则可以访问提供的所有方法 以下内容可以帮助您开始: $categoryNa

如何通过Powershell获取性能计数器的
解释文本
字符串值

我以为这是柜台的财产

Get Counter-Counter“\Processor(\u Total)\%Processor Time”\gm

(获取计数器'\logicalDisk(*)\Avg.磁盘队列长度')。计数器采样| gm


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

如果您可以调用.net framework对象,则可以访问提供的所有方法

以下内容可以帮助您开始:

$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