Tuesday, December 13, 2016

Powershell: Monitor ICMP Ping with Timestamps for Logging

Ping is the most basic and the most oldest built-in tool, that every system/network administrator cannot live without when troubleshooting network connection at TCP/IP Layer-3. I sometimes had to make long time ping test for network latency issues. Test-Connection is introduced since powershell 2.0. But, I found some issues while doing test-connection to some remote hosts, that is unable to display output instantly on console for some servers. Morever, it's unable to display the timestamp when the server is pinging its destination. So, using the built-in ping.exe, I re-write some wrap-up to suite for logging purpose with the display of timestamp & write to file in the background, using .net call & Tee-Object.
What this script will do:
1) It will ping the specified destination host by 32 bytes of data for 10 minutes by default
2) It will write the output to file in the background while it pings to specified host.
Example Usage:
To make continuous ping to 192.168.43.1 from my machine for 10 hours:
.\Smart_Ping 192.168.43.1 -hr 10

I write some comments in the script for reader's clearance. The image shown here is doing on my testing home machine.

Fig-1: Ping Result (Test by disconnect & reconnect Network)


3 comments:

  1. Good morning, I would like to know if you have any variant of this script, so you can ping two remote PCs between them.
    example
    i am pc1
    I want to test ping between pc2 and pc3, in the same format.

    ReplyDelete
  2. Nice Blog, Best best microsoft office deals for Mac Home and Business edition is a powerful suite which fulfils the productivity applications, written for Mac OS X.

    ReplyDelete
  3. I just want to thank you for sharing your information and your site or blog this is simple but nice Information I’ve ever seen i like it i learn something today. Teams Usuario

    ReplyDelete

Note: Only a member of this blog may post a comment.