1 / 2

Open ports on the local PC with a simple PowerShell script

A simple, ready-to-run PowerShell script that allows you to get the list of open ports on the Windows system and understand which applications and which users are using them.<br>Netstat is a command integrated into the various Windows versions that allow you to obtain a list of the TCP and UDP ports open on the system in use. This is a very versatile command, which we talked about at the time in the article How to check open ports on routers and public IPs and which we recommend using by opening the command prompt with administrator rights (write cmd in the search box of Windows then press the key combination CTRL SHIFT ENTER ) using the following syntax: netstat -naob.

Download Presentation

Open ports on the local PC with a simple PowerShell script

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Open ports on the local PC with a simple PowerShell script A simple, ready-to-run PowerShell script that allows you to get the list of open ports on the Windows system and understand which applications and which users are using them. Netstat is a command integrated into the various Windows versions that allow you to obtain a list of the TCP and UDP ports open on the system in use. This is a very versatile command, which we talked about at the time in the article How to check open ports on routers and public IPs and which we recommend using by opening the command prompt with administrator rights (write cmd in the search box of Windows then press the key combination CTRL + SHIFT + ENTER ) using the following syntax: netstat -naob. The only problem with Netstat is that the output produced is tough to read. By harnessing the power of PowerShell ( Windows PowerShell, how the interface that replaces the command prompt works ) and in particular the three functions Get-Process, Get- NetTCPConnection, and Get-NetUDPEndpoint, you can get a detailed report on all communication ports in use on the system, on those listening and on those where a connection has already been established. The PowerShell script in question was made by Rob VandenBrink and presented on this page. We have made it "ready for use" and have integrated three commands that allow you to: - Know the list of all ports currently used on the machine by the operating system and all installed applications - Extract the list of open ports ( Listen ) Extract the list of connections already established ( Established )In practice, using PowerShell's filtering features; it is possible to automatically process the complete list and extract the communications bearing the " Listen and Established " labels. How to use the PowerShell script to get the list of communication ports in use on Windows To use the script, you must first download this compressed file and extract its contents to your choice (e.g., c: \ ports ).

  2. At this point, you will have to type cmd in the Windows search box and press the key combination CTRL + SHIFT + ENTER to open the command prompt with administrator rights. Here you will have to type cd c: \ ports then type ports.cmd> ports.txt && notepad ports.txt and press Enter. This will generate a text file called porte.txt and open directly with Windows Notepad. By enlarging the Notepad window, you will notice the presence of several columns: the first two show the local and remote IP addresses involved in the communication; then continue with the type of protocol used (TCP or UDP) and the port (on the local and remote system). The last columns provide information on the communication status, the user name, and the process that requested the data exchange. The first part of the report, created in the form of a text file and available for consultation using the Notepad, shows all communications; scrolling further down, you will find the list of ports currently listening ( Listen) and lower down the contacts already established ( Established ). An excellent system, immediate to use, to understand what is happening on a single PC and ascertain which programs have active server functions. To go deeper, we recommend the use of Wireshark: see the articles Wireshark, a short guide to use, and Poor connection speed: how the band is used.

More Related