Sha256: c36ee7f579c9fc3b96ee42336c1abd98f2afd01066b2cafb869605783fb16122
Contents?: true
Size: 482 Bytes
Versions: 16
Compression:
Stored size: 482 Bytes
Contents
function IsPortListening { param($portNumber, $protocol) $netstatOutput = netstat -an | Out-String $networkIPs = (Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.IPEnabled}) | %{ $_.IPAddress[0] } foreach ($ipaddress in $networkIPs) { $matchExpression = ("$ipaddress" + ":" + $portNumber) if ($protocol) { $matchExpression = ($protocol.toUpper() + "\s+$matchExpression") } if ($netstatOutput -match $matchExpression) { return $true } } $false }
Version data entries
16 entries across 16 versions & 1 rubygems