This script checks if a port is currently active or in use. It can check for active TCP and UDP connections on a specified port, by process name, or by process ID.
If the process name is svchost
, the script will find the service and display name in addition to the process name.
- PowerShell 7+
You can either download the PS1 script from here, or install using...
Install-Script IsPortActive -Force
Answer Yes to any prompts. -Force
is optional, but it will force the script to update if it is outdated.
This script is published on PowerShell Gallery.
IsPortActive [-Port <int>] [-ProcessName <string>] [-ProcessId <int>] [-Version] [-Help] [-CheckForUpdate]
Only one of the following parameters can be used at a time.
Parameter | Description |
---|---|
-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. |
Description | Command |
---|---|
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 |