Wednesday, July 27, 2022

Multithreaded TCP port check

 Whopper - first post for a long time, and a short one 👶

I wrote a multithreaded TCP port check in Powershell. You ask why? Some reasons:

  • multithreaded to test a lot of computers and ports in parallel - often required in domain connectivity scenarios
  • fast as light - try it out!
  • fully pipeline aware
  • self contained, no external dependencies
  • including RPC dynamic endpoints
  • including SSL protocol checks and certificate details

Need more? Leave a comment!

It always bogged me to use Test-NetConnection (slow as hell) or even portqry.exe (needs to be scripted and output parsed) to verify a bunch of ports against a bunch of computers. So I came up with my private solution and started from scratch in Powershell. The result is impressing.

I have a builtin default set of several ports required for proper domain functionality. I ran  this check in one of our environments, consisting of 9 domains and 91 domain controllers, resulting in roughly 800 discrete port checks. Execution time? 17 Seconds... Including DNS resolution which consumes the most part of these 17 seconds.

 Check it out here: https://github.com/daabm/PowerShell/tree/master/Scripts

Happy testing!

1 comment: