- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if remote ports are open using PowerShell?
Earlier days we were using telnet clients to check the remote port connectivity, in fact, we are still using it with cmd and PowerShell but this feature is not by default installed in OS and some companies have restrictions on installing new features including telnet.
We can leverage PowerShell to test remote port connectivity without installing telnet and with the use of the Test-NetConnection command. This command is also very useful for other diagnostics but we are focusing here for the remote port check.
To check if the remote port is open or not we can use the Test-NetConnection command and it requires -ComputerName parameter and -Port to check the remote port status.
Test-NetConnection -ComputerName Test1-Win2k12 -Port 80
ComputerName : Test1-Win2k12 RemoteAddress : 192.168.0.107 RemotePort : 80 InterfaceAlias : Ethernet0 SourceAddress : 192.168.0.106 TcpTestSucceeded : True
The above example will check Port number 80 con
ectivity on remote server Test1-Win2k12. You can see that the TcpTestSucceeded property is true so the port is open. One more example shown below is WInRM https port 5986.
Test-NetConnection -ComputerName Test1-Win2k12 -Port 5986
WARNING: TCP connect to Test1-Win2k12:5986 failed ComputerName : Test1-Win2k12 RemoteAddress : 192.168.0.107 RemotePort : 5986 InterfaceAlias : Ethernet0 SourceAddress : 192.168.0.106 PingSucceeded : True PingReplyDetails (RTT) : 0 ms TcpTestSucceeded : False
You can see that the WinRM SSL port is not open on the remote server and a warning message is displayed in the first line as well as in the TcpTestSucceeded property.
- How to restart a remote system using PowerShell?
- How to test remote computer connectivity using PowerShell?
- How to block ports on the Windows Operating System using PowerShell?
- How to remove connected remote desktop user sessions using PowerShell?
- How to check if the file is empty using PowerShell?
- How to check the PowerShell version installed in local and remote systems?
- How to get all the processes on remote computers using PowerShell?
- How to get connected remote desktop users on computers using PowerShell?
- How to check if the computer is connected to a domain using PowerShell?
- How to get services on remote computers with PowerShell?
- How to check if PSCustomObject is empty in PowerShell?
- How to check if the USB device is connected to the system using PowerShell?
- How to open a port in the Windows Operating System using PowerShell?
- How to check if the date is adjusted by Daylight saving time using PowerShell?
- How to check if the Azure resource group is empty or not using PowerShell?