param( [string]$logfile = "$env:temp\bom_ephemeralportstat.log" ) if (Test-Path($logfile)) { $ret = [int]((Select-String "Established" $logfile).Line -Replace "\D","") $ret += [int]((Select-String "CloseWait" $logfile).Line -Replace "\D","") return $ret } else { return "Error: no monitoring data." } # Or Perfmon Counter TCPv4/TCPv6\Connections Established