Sha256: ca012470fc069bad900c7e117aba0063d786f19a59f71bb4d508703861bc85c5
Contents?: true
Size: 478 Bytes
Versions: 53
Compression:
Stored size: 478 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
53 entries across 53 versions & 2 rubygems