IsPortActive — Check if a port is open/active/listening on your computer with one command in PowerShell

asheroto
2 min readMar 12, 2021

--

Lately I’ve been troubleshooting various types of networking related issues.

It is common to check for open/active/listening ports.

Unfortunately Microsoft hasn’t made this that easy — you have to connect the dots between commands, process IDs, and paths.

IsPortActive is a PowerShell script that provides a simple yet effective method to check the activity of a port on your system. It offers three different options to perform the check:

  1. By Port Number
    You can specify the port number to check for active connections.
  2. By Process Name
    You can specify the name of the process to check active connections.
  3. By Process ID
    You can specify the process ID to check for active connections.

If the process name is svchost, the script will find the service and display name in addition to the process name.

Usage

IsPortActive [-Port <int>] [-ProcessName <string>] [-ProcessId <int>] [-Version] [-Help] [-CheckForUpdate]

Parameters

Only one of the following parameters can be used at a time.

  • -Port: Specifies the port number to check for active connections.
  • -ProcessName: Specifies the name of the process to check for active connections.
  • -ProcessId: Specifies the process ID to check for active connections.
  • -Version: Displays the version of the script.
  • -Help: Displays the help information for the script.
  • -CheckForUpdate: Checks for updates of the script.

Examples

To provide further clarity on how to use IsPortActive, let’s look at a few examples:

  • Check if port 443 is active:
    IsPortActive -Port 443
  • Check what ports are being used by process httpd:
    IsPortActive -ProcessName “httpd”
  • Check what ports are being used by process ID 1234:
    IsPortActive -ProcessId 1234

By following these steps and utilizing appropriate parameters, you can effectively use IsPortActive to check the status of ports on your system.

Consider becoming a Medium member if you appreciate reading stories like this and want to help me as a writer. It costs $5 per month and gives you unlimited access to Medium content. I’ll get a little commission if you sign up via my link.

--

--

asheroto
asheroto

Written by asheroto

🌎 Full Stack Developer 🔗 Systems Administrator 😎Innovation through Automation ✔ Privacy Advocate ♥ Startup Facilitator

No responses yet