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