Sha256: f0a22a5fcb55ab30c45319087e5c00e380f304e56d0270b87d9a2b94014d506f
Contents?: true
Size: 551 Bytes
Versions: 144
Compression:
Stored size: 551 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" foreach ($ipaddress in $networkIPs) { $matchExpression = ("$ipaddress" + ":" + $portNumber) if ($protocol) { $matchExpression = ($protocol.toUpper() + "\s+$matchExpression") } if ($netstatOutput -match $matchExpression) { return $true } } $false }
Version data entries
144 entries across 144 versions & 2 rubygems