Thor Logo dbatools

Remove-DbaPfDataCollectorCounter

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

Synopsis

Removes specific performance counters from Windows Performance Monitor Data Collector Sets.

Description

Removes performance counters from existing Data Collector Sets in Windows Performance Monitor. This allows you to clean up monitoring configurations by removing counters that are no longer needed, reducing resource consumption and focusing on relevant metrics. Commonly used when fine-tuning SQL Server performance monitoring setups or removing counters that were added for troubleshooting specific issues.

Syntax

Remove-DbaPfDataCollectorCounter
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [[-CollectorSet] <String[]>]
    [[-Collector] <String[]>]
    [-Counter] <Object[]>
    [[-InputObject] <Object[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Remove-DbaPfDataCollectorCounter -ComputerName sql2017 -CollectorSet 'System Correlation' -Collector DataCollector01  -Counter '\LogicalDisk(*)\Avg. Disk Queue Length'

Prompts for confirmation then removes the ‘\LogicalDisk(*)\Avg. Disk Queue Length’ counter within the DataCollector01 collector within the System Correlation collector set on sql2017.

Example: 2
PS C:\> Get-DbaPfDataCollectorCounter | Out-GridView -PassThru | Remove-DbaPfDataCollectorCounter -Confirm:$false

Allows you to select which counters you’d like on localhost and does not prompt for confirmation.

Required Parameters

-Counter

Specifies the exact performance counter name(s) to remove from the data collector. Must use the full counter path format like ‘\Processor(_Total)% Processor Time’ or ‘\SQLServer:Buffer
Manager\Buffer cache hit ratio’.
Use this when you need to remove specific SQL Server or system performance counters that are no longer needed for monitoring, such as counters added for troubleshooting that are now consuming
unnecessary resources.

PropertyValue
AliasName
RequiredTrue
Pipelinetrue (ByPropertyName)
Default Value

Optional Parameters

-ComputerName

Specifies the target computer(s) where the Performance Monitor Data Collector Set is configured. Accepts multiple computer names for bulk operations.
Use this when you need to remove counters from collector sets on remote SQL Server machines or when managing performance monitoring across multiple servers.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value$env:COMPUTERNAME
-Credential

Allows you to login to the target computer using alternative credentials. To use:
$cred = Get-Credential, then pass $cred object to the -Credential parameter.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-CollectorSet

Specifies the name of the Performance Monitor Data Collector Set containing the counters to be removed. Supports wildcards for pattern matching across multiple sets.
Use this when you know the specific collector set name where your performance counters are configured, such as ‘System Correlation’ or custom SQL Server monitoring sets.

PropertyValue
AliasDataCollectorSet
RequiredFalse
Pipelinefalse
Default Value
-Collector

Specifies the name of the individual data collector within the collector set that contains the performance counters to remove. Supports multiple collector names.
Use this to target specific data collectors when your collector set contains multiple collectors, allowing you to remove counters from only the collectors you specify.

PropertyValue
AliasDataCollector
RequiredFalse
Pipelinefalse
Default Value
-InputObject

Accepts performance counter objects from Get-DbaPfDataCollectorCounter via the pipeline, allowing you to remove counters discovered through previous queries.
Use this when you want to first review existing counters with Get-DbaPfDataCollectorCounter and then selectively remove specific ones through pipeline operations.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value