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

Version Path
specinfra-0.2.1 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.2.0 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.1.1 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.1.0 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.17 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.16 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.15 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.14 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.13 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.12 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.11 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.10 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.9 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.8 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.7 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.6 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.5 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.4 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.3 lib/specinfra/backend/powershell/support/is_port_listening.ps1
specinfra-0.0.2 lib/specinfra/backend/powershell/support/is_port_listening.ps1