Invoke-xRDS_TestPort.ps1

1
2
3
4
5
6
7
8
9
function Invoke-xRDS_TestPort ($hostname='localhost',$port=5985,$timeout=100) {
      $requestCallback = $state = $null
      $client = New-Object System.Net.Sockets.TcpClient
      $beginConnect = $client.BeginConnect($hostname,$port,$requestCallback,$state)
      Start-Sleep -milli $timeOut
      if ($client.Connected) { $open = $true } else { $open = $false }
      $client.Close()
      [pscustomobject]@{hostname=$hostname;port=$port;open=$open}
    }