• RSS
  • Twitter
  • FaceBook

A Quick Tip To Check If A Port Is Listening On Multiple Computers

This article explains how you can check if a port is listening on multiple computers.

On local computer you can always run NetStat -an command to get the list of all the ports listening on the computer. There is no support available natively on Windows Computers or there is no command line tool available to check if a specific port is listening on multiple computers or not. Let's assume we want to check if 3389 port is listening or not on the servers mentioned in the Servers.txt file. To accomplish this, you need to use the script mentioned below:

Steps:

  • 1. Create a text file: Servers.txt
  • 2. Put all the Server Names in it.
  • 3. Next, copy the following lines in a file and save it save it as CheckPort.CMD
  • REM ***START HERE***
  • Echo Off
  • SetLocal EnableDelayedExpansion
  • IF EXIST Result.csv DEL Result.csv
  • FOR /F "Tokens=*" %%L IN (Servers.txt) DO (
  •    SET ServerName=
  •    SET ServerName=%%L
  •    Psexec.exe \\!ServerName! NetStat -an > Result.txt
  •    Find /i "3389" < Result.txt
  •    IF !ErrorLevel! == 0 (
  •        Echo !ServerName!, Listening >> Result.CSV
  •    ) ELSE (
  •        Echo !ServerName!, Not Listening >> Result.csv
  •    )
  • )
  • REM ***END HERE***

The end result will be stored in a file called Result.csv.

About Nirmal Sharma

Nirmal is a Microsoft MVP in Directory Services and working as a Technical Architect/Consultant. He has been involved in Microsoft Technologies since 1994 and followed the progression of Microsoft Operating Systems and software. He is specialized in Directory Services, Microsoft Clustering, SQL, MOM, Exchange and Citrix. In his spare time, he likes to help others and write "internal" technical articles, white papers and tips on various Microsoft technologies. You can contact him at nirmal_sharma@mvps.org.


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred data recovery solution?