Menu Close

Testing to see if a port is open to a SCOM server when you don’t have Portqry or Telnet


Something that I run across a lot in helping clients test connectivity issues in firewalled environments, is “is there a firewall blocking port 5723 traffic?”

In the past we would use tools like Telnet, or Portqry to test port connectivity, but often this is not installed and not easily available.  Luckily, we always have PowerShell!

 

Here is a quick and dirty PowerShell script you can run as a single line, to test name resolution and port availability.  Just change the $server value in quotes.

 

$server="scom2.opsmgr.net";$ip=([System.Net.Dns]::GetHostAddresses($server)).IPAddressToString;$tcp=New-Object net.sockets.tcpclient;$tcp.Connect($server,5723);$out=$tcp.Connected;write-host "`nPort 5723 test result for ($server) on IP ($ip) : ($out)"

 

Here it is as a script, if you want to see it all, but not on a single line:

 

$server="scom2.opsmgr.net"; $ip=([System.Net.Dns]::GetHostAddresses($server)).IPAddressToString; $tcp=New-Object net.sockets.tcpclient;$tcp.Connect($server,5723); $out=$tcp.Connected; write-host "`nPort 5723 test result for ($server) on IP ($ip) : ($out)"

 

The output:

image

 

You can also use a simpler command, “Test-NetConnection”  However, this command is only available starting in PowerShell V4, so it might not be available on all systems with older PowerShell installations.  V4 was included by default starting with Windows Server 2012R2.

 

Test-NetConnection -Port 5723 -ComputerName scom2.opsmgr.net

The output:

image

1 Comment

  1. Kumar

    Fantastic, when i was serving Microsoft as vendor it used to be a default installation of this little tool on all servers but moving to small organisations it wasnt, i was always copying the Portqry tool to local machine to do the query… but with this 🙂 …

Leave a Reply

Your email address will not be published. Required fields are marked *