Pages

3/27/2011

PING test

PowerShell to PING a list of computers.

##########################################################################
# 
#    PING List of Machines
#
##########################################################################

$computers = get-content list.txt
$ping = new-object system.net.networkinformation.ping
$pingreturns = @()
foreach ($entry in $computers) {
  $entry = $entry -replace "\s{2,}", ""
  if ($entry.length -eq 0) {$entry = 'NOTHING'}
  $result = $entry+" "+(Test-Connection -ComputerName $entry -quiet -count 1)
  $result
  $result | out-file -encoding ASCII -filepath RESULT.TXT -append
  }#foreach

No comments: