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:



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:


Comments (2)

  1. Edwio says:

    Thanks Kevin, for another great and useful tip.

Skip to main content