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? Is there a port checker for that?
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 port checker 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.

port checker

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

My new book :  PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at [email protected]

Optical Character Recognition

Subscribe to our mailing list

* indicates required