Tuesday, 17 June 2025

SQL_DBA- Ip Address Ping

Start-Transcript -path C:/Script/PingLog.txt -Append 




Ping.exe -t spiceworks.com | ForEach {"{0} - {1}" -f (Get-Date),$_}

Lets break this down real quick.

  1. Ping.exe - That’s ping! powershell can use your CMD stuff just fine.

  2. -t is as we all know, a continuous ping. can go before or after our hostname/IP address.

  3. spiceworks.com is what we’re pinging.

  4. Next up is a pipe (|) - We’re sending our information over to our next command.

  5. Foreach is the next thing in our command here.

  6. [“{0} - {1}” -f] - This is the text formatting, check the references below if you’d like to learn more

  7. (Get-Date) - This is the date! it’s also what’s going into {0} in the text formatting above.

  8. $_ - This is you taking your previous input from ping and putting into {1} 


No comments:

Post a Comment

SQL_DBA- Ip Address Ping

Start-Transcript - path C:/Script/PingLog.txt -Append   Ping.exe -t spiceworks.com | ForEach { "{0} - {1}" -f (Get-Date), $_ } ...