Query Port Information using Powershell


Have you ever googled a port number to figure out what service uses it? I think every system administrator must have done this. But how to approach when there are a lot of port numbers to search?
So, I thought giving it a try with PowerShell, to programmatical get port information of lots of port numbers.

The Idea and Making it work:

  1. First get information for all the ports, but where to get it? I read somewhere during my engineering graduation days, that port numbers are assigned by IANA (Internet Assigned Numbers Authority). How about checking their website first.So I found a link on IANA’s website which has port numbers in a CSV format and downloaded the file.


  2. Once you have the information, filter out all unnecessary things and store them in a CSV or JSON format, so that it can be easily uploaded/downloaded from a Public Github gist.Using the below script I filtered out the required information and pasted/committed it to my Github repository  , from where it could be downloaded to any machine since it is Public.

  3. Write a Powershell function that can
    1. Web request above mentioned public Github gist URL and downloads the content.
    2. Filter out port number you’re trying to search from the content, and display the results

      Following is the PowerShell function to get above done

  4. Make sure when the Powershell function runs for the first time, it creates a local copy of content in a File at a static location, which could be accessed to get port information locally for all Future function calls by avoiding the Web request which is slower.Took care of point-6 in my PowerShell function like in the screenshot belowcnd

Running the Function:

You can run the function on demand like in the below screenshot.

Please Note – The First call to the function would be slow, but from the next call you have a local copy of the CSV file on your machine, which can be queried comparatively much faster to web requests.


Hope you’ll find the script useful and Thanks for reading, Cheers! 🙂



10 thoughts on “Query Port Information using Powershell

  1. Thank you for sharing superb informations. Your web-site is fantastically cool. I am impressed by the details that you have proceeding this web site. It reveals how nicely you perceive this subject. Bookmarked this web call, will be as long as backside in support of more articles. You, my friend, ROCK! I originate simply the info I previously searched all more than the place and just couldn’t extend athwart. Could you repeat that? an ideal trap site.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s