Day 67: Troubleshooting Tools – Host DNS and Port Test Script

This week, I will be discussing a Script that I wrote to check DNS Resolution and the availability of Network Ports on multiple hosts. (More Chef related Articles will be coming in future installments).

If you have read the previous blog post, Day 6 – Configuring an HTTPS DSC Pull Server, you may find the Script below useful for troubleshooting configuration issues that are directly related to connectivity between hosts.

 

The current iteration of the script is shown below. Additionally, it is available from my GitHub Repository.

 

 

Example

In the example below, I am testing connectivity from an Orchestrator Server, SCORCH154, to 5 other hosts on the following port numbers: 80, 81, 82, 3389, 5985, 5723, and 443. The syntax to run this scan is shown below:

 

 

The names of the Hosts to test against are located in the same directory as the Script in a file called Hosts.txt. (Note that the first line of the Hosts.txt file is Hostname.)

The output from the script is returned in the following order: Source (Host Testing From), Destination (Host Test To), Port Number_x, Port Number_y, Port Number_z, etc…

A screenshot of the output in the PowerShell Console is below:

temp1

 

Additionally, the results will be returned in CSV Format to a file called Host_DNS_and_Port_Check_Results_<TIMESTAMP>.csv that resides in the same directory as the Script.

 

The output of the results from the screenshot above are shown below:

 

Conclusion

This week’s post has demonstrated how to check DNS Resolution and the availability of Network Ports on multiple hosts using the Host_DNS_and_Port_Test_v1.0.ps1 PowerShell Script.

 

Previous Installments

100 Days of DevOps with PowerShell

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.