Remove-HeatmapCounter.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function Remove-HeatmapCounter
{
    <#
    .Synopsis
        Removes a performance counter from the heatmap
    .Description
        Removes a performance counter to the heatmap.
    .Example
        Remove-HeatmapCounter '\Processor(_total)\% Processor Time'
    .Link
        Get-HeatmapCounter
    .Link
        Add-HeatmapCounter
    .Link
        Watch-Heatmap
    #>

    [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='High')]
    param(
    # The name of the performance counter to remove from the heatmap
    [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [string]
    $Name
    )
    
    
    process {
        #region Make sure it exists
        if (-not $script:HeatMapCounters[$Name]) {
            Write-Error "$Name not found"
            return
        }
        #endregion
        
        #region Remove It
        if ($psCmdlet.ShouldProcess($Name)) {
            $null = $script:HeatMapCounters.Remove($Name)
        }
        #endregion Remove It
    }
    
}