我对主题中的问题感到不安。
我有这段代码:
$category_name = "JCM"
$counter_name = "counter5"
$categoryExists = [System.Diagnostics.PerformanceCounterCategory]::Exists($category_name)
# If category does not exist yet:
If (-Not $categoryExists)
{
[System.Diagnostics.PerformanceCounterCategory]::Create($category_name, "", [System.Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $counter_name, "") | Out-Null
}
# create counter:
$perfmonCounter = New-Object System.Diagnostics.PerformanceCounter($category_name, $counter_name, "", $false)
Write-Host ($perfmonCounter | Format-List | Out-String)
$perfmonCounter.RawValue = 0
我第一次运行它 - 它会创建类别和计数器。 但是当我将计数器名称更改为计数器6时,它不会将其添加到类别中! 这是althogh写主持人告诉我这个:
CategoryName:JCM CounterHelp:CounterName:counter6 CounterType:InstanceLifetime:Global InstanceName: ReadOnly:False MachineName :. RawValue:0 网站:容器:
这里有什么问题?
我运行Window 7 64位,PowerShell 4.0,.Net 4.5
谢谢。