在PowerShell脚本或命令行中创建和编辑性能计数器

我试图移动验证创建我的性能计数器组,以及计数器本身,从我的Web服务中,并进入部署期间运行的powershell脚本.

这可以做吗或者我使用一个简单的应用程序来建立群组&柜台?

非常感谢 :)

以前看过这个,但从未张贴过.
这是我的解决方案:

//save out the type name for sanity's sake
$ccdTypeName = 'System.Diagnostics.CounterCreationData'
$CounterCollection = New-Object System.Diagnostics.CounterCreationDataCollection

//create as many counters as we'd like, and add them to the collection. here's just one:
$CounterCollection.Add( (New-Object $ccdTypeName "Counter Name", "Counter Description", NumberOfItems32) )

//create the category with the counter collection
[System.Diagnostics.PerformanceCounterCategory]::Create($perfCounterCategoryName, $perfCounterVersion, [Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $CounterCollection); 
翻译自:https://stackoverflow.com/questions/3605146/creating-editing-performance-counters-in-a-powershell-script-or-command-line

转载注明原文:在PowerShell脚本或命令行中创建和编辑性能计数器