Show-HTNetworkConnections.ps1

function Show-HTNetworkConnections {
    [CmdletBinding()]
    param (
        # Set this switch to monitor continuously
        [switch]$Continuous,

        # Refresh Rate (seconds)
        [Parameter()]
        [int16]$RefreshPerSecond = 1
    )
    process {
        $continue = $true
        While($continue)
        {

            $stat = [pscustomobject]@{ Established = 0; TimeWait = 0}

            netstat -ant | Set-Variable -Name nt

            $nt | findstr EST | Measure-Object -OutVariable est | Out-Null
            $nt | findstr TIME | Measure-Object -OutVariable tmwait | Out-Null
            Start-Sleep -Seconds $RefreshPerSecond
            $stat.Established = $est[0].Count
            $stat.TimeWait = $tmwait[0].Count
            Clear-Host
            $stat | Format-Table

            if(-not $Continuous) { $continue = $false}
        }
    }

}