#Ping multiple computers and output to text file code#
The code put it in loop so it will ping continuously. And display “Request timed out” then wait for some title. If it is failed the background color will change to red. Prompting an IP address and set to a variable named %IP%, and its pinging once with 32 bytes of data.
Here is the script to do the ping with color output results. /bin/bash Program name: pingall.sh date cat /path/to/list.txt while read output do ping -c 1 output > /dev/null if -eq 0 then echo node. And the default success pings with a green background. But it will be better to show a red window if the Request timed out. Normal command line is with a black colour background and white text.
Read-Host 'Press Enter to continue.' | Out-NullĪfter the script completes going through the list of computers, you would be able to take the pingable text file and connect to those C$ shares and drill down to the user profile folder to find out who has logged in to the computer recently and hopefully help locate the computer.We are using ping command to monitor the networks, Sometimes we have to monitor multiple IP address with continuous ping in different windows. PowerShell script pings the servers from that list, parses the output of the ping command and stores only the following portion it into the different file line by line: Reply from 192.168.10.10: bytes32 time<1ms TTL128 Reply from 192.168.10. $report | Out-File -FilePath $faillog -Append There is a file which contains a list of servers. $report = ::concat($PC, " was not pingable.") $report | Out-File -FilePath $successlog -Append $report = ::concat($PC, " is pingable with ", $pingable2.IPV4Address) I don't need the time or other information I just would like to know reachable or not. Is it possible to create a batch file that is pinging all of these computers And actually a ping is a big output. Write-Host $PC "is pingable with" $pingable2.IPV4Address Lets say I have here a text file with some computer names (each line 1 name): computerA computerB computerC. $pingable2 = test-connection -ComputerName $PC -Count 1 $pingable = test-connection -ComputerName $PC -Count 2 -quiet # loop through above array of each computer and test pinging to them. Write-Host "Testing connection to computers listed in ping.txt" $faillog = ::concat($Env:userprofile, "Desktopnotpingable_", $timestamp,".txt") $successlog = ::concat($Env:userprofile, "Desktoppingable_", $timestamp,".txt") $ScriptPath = Split-Path -Parent -Path $MyInvocation.M圜ommand.Definition & would run the next command, if the previous command ere successful. > /dev/null redirects the output, so you wont see it. ping -o exits the ping after the first packet is received. # List computer name (not FQDN) in ping.txt in the same directory as this script ping -oc 100000 Hostname > /dev/null & /root/scripts/test1.sh.
bat file is picking up the file I want with all my IP addresses (IPS.txt), however, I am wanting my ping results to be in a text file ping.txt. # Ping a number of computers and report the successful ones. .bat to ping multiple computers from text file and output results to text file mcranda M mcranda New Member Joined Messages 19 1 Here is the code I have so far. domain.fqdn with your own fully qualified domain name, so it is appended to each computer name. I considered making it a circular log so the non-responding computers would be filtered and ready for the next round of running the script but kept with this direction to keep things more straight-forward. The computers that do not reply to the ping are logged to a text file on the desktop named notpingable_timestamp. The computers that are successfully pinged are pinged one more time to get their IP address (more information to use in tracking them down) and are logged in a text file to the desktop as text file named pingable_. Ping.txt should reside in the same folder as the script. This PowerShell script reads from a text file ping.txt with each computer name on its own line and then uses test-connection to ping the computer.