Install-PerformanceCounter

Installs a performance counter.

Syntax

Install-PerformanceCounter -CategoryName <String> -Name <String> [-Description <String>] -Type {NumberOfItemsHEX32 | NumberOfItemsHEX64 | NumberOfItems32 | NumberOfItems64 | CounterDelta32 | CounterDelta64 | SampleCounter | CountPerTimeInterval32 | CountPerTimeInterval64 | RateOfCountsPerSecond32 | RateOfCountsPerSecond64 | RawFraction | CounterTimer | Timer100Ns | SampleFraction | CounterTimerInverse | Timer100NsInverse | CounterMultiTimer | CounterMultiTimer100Ns | CounterMultiTimerInverse | CounterMultiTimer100NsInverse | AverageTimer32 | ElapsedTime | AverageCount64 | SampleBase | AverageBase | RawBase | CounterMultiBase} [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Install-PerformanceCounter -CategoryName <String> -Name <String> [-Description <String>] -Type {NumberOfItemsHEX32 | NumberOfItemsHEX64 | NumberOfItems32 | NumberOfItems64 | CounterDelta32 | CounterDelta64 | SampleCounter | CountPerTimeInterval32 | CountPerTimeInterval64 | RateOfCountsPerSecond32 | RateOfCountsPerSecond64 | RawFraction | CounterTimer | Timer100Ns | SampleFraction | CounterTimerInverse | Timer100NsInverse | CounterMultiTimer | CounterMultiTimer100Ns | CounterMultiTimerInverse | CounterMultiTimer100NsInverse | AverageTimer32 | ElapsedTime | AverageCount64 | SampleBase | AverageBase | RawBase | CounterMultiBase} -BaseName <String> [-BaseDescription <String>] -BaseType {NumberOfItemsHEX32 | NumberOfItemsHEX64 | NumberOfItems32 | NumberOfItems64 | CounterDelta32 | CounterDelta64 | SampleCounter | CountPerTimeInterval32 | CountPerTimeInterval64 | RateOfCountsPerSecond32 | RateOfCountsPerSecond64 | RawFraction | CounterTimer | Timer100Ns | SampleFraction | CounterTimerInverse | Timer100NsInverse | CounterMultiTimer | CounterMultiTimer100Ns | CounterMultiTimerInverse | CounterMultiTimer100NsInverse | AverageTimer32 | ElapsedTime | AverageCount64 | SampleBase | AverageBase | RawBase | CounterMultiBase} [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Creates a new performance counter with a specific name, description, and type under a given category. The counter's category is re-created: its current counters are retrieved, the category is removed, a the category is re-created. Unfortunately, we haven't been able to find any .NET APIs that allow us to delete and create an existing counter.

If you're creating a performance counter that relies on an accompanying base counter, use the BaseName, BaseDescription, and BaseType parameters to properly add the base counter.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
CategoryName String

The category's name where the counter will be created.

true false
Name String

The performance counter's name.

true false
Description String

The performance counter's description (i.e. help message).

false false
Type PerformanceCounterType

The performance counter's type (from the Diagnostics.PerformanceCounterType enumeration).

true false
BaseName String

The base performance counter's name.

true false
BaseDescription String

The base performance counter's description (i.e. help message).

false false
BaseType PerformanceCounterType

The base performance counter's type (from the Diagnostics.PerformanceCounterType enumeration).

true false
Force SwitchParameter

Re-create the performance counter even if it already exists.

false false False
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

EXAMPLE 1

Install-PerformanceCounter -CategoryName ToyotaCamry -Name MilesPerGallon -Description 'The miles per gallon fuel efficiency.' -Type NumberOfItems32

Creates a new miles per gallon performance counter for the ToyotaCamry category.

EXAMPLE 2

Install-PerformanceCounter -CategoryName "Dispatcher" -Name "Average Dispatch time" -Type AverageTimer32 -BaseName "Average Dispatch Base" -BaseType AverageBase -Force

Creates a counter to collect average timings, with a base counter. Some counters require base counters, which have to be added a specific way to work properly.