I am trying to create Performance Counters using PowerShell, but am getting the following error due to my use of AverageCount64:
"The Counter layout for the Category specified is invalid, a counter of the type: AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns,CounterMultiTimer100NsInverse, RawFraction, or SampleFraction has to be immediately followed by any of the base counter types: AverageBase, CounterMultiBase, RawBase or SampleBase."
I know that I need to add AverageBase for the types that are AverageCount64 but am unsure how to add that in my code, especially since I have types (RateOfCountsPerSecond64) that don't require AverageBase:
$AnalyticsCollection = New-Object System.Diagnostics.CounterCreationDataCollection $AnalyticsCollection.Add( (New-Object $ccdTypeName "Aggregation | Total Aggregation Errors / sec", "The total number of interactions which could not be aggregated due to an exception.", RateOfCountsPerSecond64) ) $AnalyticsCollection.Add( (New-Object $ccdTypeName "Aggregation | Average Check Out Time - History (ms)", "Average time it takes to obtain a work item from a range scheduler while rebuilding the reporting database.", AverageCount64) ) $AnalyticsCollection.Add( (New-Object $ccdTypeName "Collection | Total Visits / sec", "The total number of visits per second that are registered by the system.", RateOfCountsPerSecond64 ) ) $AnalyticsCollection.Add( (New-Object $ccdTypeName "Aggregation | Average Check In Time - History (ms)", "Average time it takes to mark a work item as completed in a range scheduler while rebuilding the reporting database.", AverageCount64) ) [System.Diagnostics.PerformanceCounterCategory]::Create("My Counters", "I love my performance counters", [Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $AnalyticsCollection) | out-null