ConvertFrom-PerformanceCounter.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
function ConvertFrom-PerformanceCounter {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory,ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [array]
        $InputObject
        ,
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]
        $Instance
    )

    Process {
        $InputObject | ForEach-Object {
            [pscustomobject]@{
                Timestamp = $_.Timestamp
                Value     = $_.CounterSamples | Where-Object { $_.InstanceName -ieq $Instance } | Select-Object -ExpandProperty CookedValue
            }
        }
    }
}

New-Alias -Name cfpc -Value ConvertFrom-PerformanceCounter -Force