Public/Get-SurfBoardForwardErrorCorrection.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
44
45
46
47
48
49
50
51
Function Get-SurfBoardForwardErrorCorrection {
    [CmdletBinding(SupportsShouldProcess=$True)]
    Param (
        [Parameter(ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true)]
        [Alias("CN", "SurfBoard", "SB")]
        [String[]]
        $ComputerName = $surfboard
    )
    Begin {
        Write-Verbose "Begin $($MyInvocation.MyCommand)"
    }
    Process {
        if ($PSCmdlet.ShouldProcess($ComputerName)) {
            $codewords = Get-SurfBoardSignalStatus -ComputerName $ComputerName
            $fecs = @()
            $unerrored = $($codewords.'Total Unerrored Codewords' | Measure-Object -Sum).Sum
            $corrected = $($codewords.'Total Correctable Codewords' | Measure-Object -Sum).Sum
            $uncorrected = $($codewords.'Total Uncorrectable Codewords' | Measure-Object -Sum).Sum
            $errored = $corrected + $uncorrected
            $total = $unerrored + $errored
            $fec = [ordered]@{}
            $fec.'Channel ID' = "All"
            $fec.'Unerrored (%)' = $unerrored/$total*100
            $fec.'Errored (%)' = $errored/$total*100
            $fec.'Errors Corrected (%)' = $corrected/$errored*100
            $fec.'Errors Uncorrected (%)' = $uncorrected/$errored*100
            $fecs += $fec
            foreach ($codeword in $codewords) {
                $fec = [ordered]@{}
                $channel = $codeword.'Channel ID'
                $unerrored = $codeword.'Total Unerrored Codewords'
                $corrected = $codeword.'Total Correctable Codewords'
                $uncorrected = $codeword.'Total Uncorrectable Codewords'
                $errored = $corrected + $uncorrected
                $total = $unerrored + $errored
                $fec.'Channel ID' = $channel
                $fec.'Unerrored (%)' = $unerrored/$total*100
                $fec.'Errored (%)' = $errored/$total*100
                $fec.'Errors Corrected (%)' = $corrected/$errored*100
                $fec.'Errors Uncorrected (%)' = $uncorrected/$errored*100
                $fecs += $fec
            }
            Return $fecs
        }
    }
    End {
        Write-Verbose "End $($MyInvocation.MyCommand)"

    }
}
Set-Alias -Name gsbfec -Value Get-SurfBoardForwardErrorCorrection