Skip to main content
Announcements
Marching toward a simplified navigation! READ ON

How To Check Open Ports Using PowerShell

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Mario_Petre
Support
Support

How To Check Open Ports Using PowerShell

Last Update:

Aug 10, 2023 2:11:33 PM

Updated By:

Chip_Matejowsky

Created date:

Jun 3, 2016 10:53:27 AM

Attachments

There are quick ways to determine if a port is listening on a particular server using PowerShell instead of requiring the telnet client feature to be installed, or relying on third-party tools. 

Alternatively, Qlik Sense comes shipped with Qlik Sense Utility, which includes a Port Checker. See Qlik Sense Utility - Functions and Features.

For more information about required ports for Sense and QlikView:

 

Using a Test-PortConnection function (Windows Server 2012 and later)

Before you can carry out this step:

  1. Open PowerShell
  2. Copy the content of the attached test_portconnection.txt 
  3. Paste into PowerShell
  4. Hit return

After this, you can use the following: 

Test-NetConnection -ComputerName hostname -Port 4747


Example Qlik Sense:

Test-PortConnection -Destination localhost -Ports 80,443,4239,4241,4242,4243,4244,4248,4432,4444,4545,4555,4570,4747,4748,4899,4900,4949,5050,5151,5252

Example NPrinting:

Test-PortConnection -Destination localhost -Ports 443,4242,4243,4730,4747,4799,4992,4993,4994,4995,4996,4997,5672,15672

 


Related Content:

Labels (1)
Comments
a_mullick
Creator III
Creator III

Hi,

Can I just check the logic in the attached powershell script? It returns success or fail depending on the results of PingSucceeded.  If I run it on these two ports I get:

PS C:\Windows\system32> Test-PortConnection -Destination localhost -Ports 4241,4242
WARNING: TCP connect to localhost:4241 failed

Destination Port 4241 Port 4242
----------- --------- ---------
localhost Success Failure

But should the results not be the other way around? I.e. port 4242 is accepting TCP traffic, but port 4241 is not accepting TCP traffic (however, the server is up and is responding to an generic ping)?

Results from Test-NetConnection:

PS C:\Windows\system32> Test-NetConnection -Port 4242 -ComputerName localhost -InformationLevel Detailed

ComputerName : localhost
RemoteAddress : 127.0.0.1
RemotePort : 4242
NameResolutionResults : 127.0.0.1
::1
MatchingIPsecRules :
NetworkIsolationContext : Loopback
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
NetRoute (NextHop) : 0.0.0.0
TcpTestSucceeded : True

PS C:\Windows\system32> Test-NetConnection -Port 4241 -ComputerName localhost -InformationLevel Detailed
WARNING: TCP connect to localhost:4241 failed

ComputerName : localhost
RemoteAddress : 127.0.0.1
RemotePort : 4241
NameResolutionResults : 127.0.0.1
::1
MatchingIPsecRules :
NetworkIsolationContext : Loopback
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
NetRoute (NextHop) : 0.0.0.0
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False

Thanks,

Azam

ifytra
Contributor III
Contributor III

Dear Mario,

 

Thanks for the useful post. In case you use a system in which running Powershell scripts is disabled / restricted, then you may use PortQry  provided by Microsoft (URL: https://www.microsoft.com/en-us/download/details.aspx?id=17148) 

 

Many thanks,

Ilias

Version history
Last update:
‎2023-08-10 02:11 PM
Updated by: