Вопрос

How can I get a Performance counter's Explain Text's string value thru Powershell.

enter image description here

I thought it would be a property of a counter

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

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

But it isn't. I found Lodctr /q to query the counters and this. However, I can't find exactly how to get the string value.

Это было полезно?

Решение

If you are ok with calling .net framework objects you have access to all the methods provided by PerformanceCounterCategory.

The following should help you get started:

$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 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top