Mass Ping Tool.txt - Notepad

Mass Ping Tool

The below PowerShell script reads a text or csv file of hostnames and then reports the result.

$nl = [Environment]::NewLine
Write-Host "Welcome to the Mass Ping Tool - Author Nick Beare"
$nl
$ping_path = read-host "Please enter the path of the csv or txt
file containing the hostnames you would
like to ping eg c:\folder\hostnames.txt. Please note, each hostname
must be listed on a separate line in your
input file, although whitespace at either
end of a hostname is accepted
" $date = get-date -f ssddMMyyyy $file = $date + "ping_results.txt" $nl $username = $env:username $target = "c:\users\" $target2 = $target + $username write-host "Please wait while your ping results are generated below.
A copy of the results can also be found at $target2
" $nl $index = 0 get-content $ping_path | foreach { if (test-connection $_.trim() -quiet) { write-output "$_ pingable" | out-file c:\users\$env:username\$file -append } else { write-output "$_ down" | out-file c:\users\$env:username\$file -append } get-content c:\users\$env:username\$file | select -index $index $index = $index + 1 }

Back