Thursday 4 October 2012

Ping Server List Availability (ICMP)

Task:
Please make sure that all servers are ping from your PC. Here is 'serverlist.txt'.

So:
# get file content
$file = Get-Content 'C:\serverlist.txt'
# convert file content into string type
[string]$lines = $file
# split our string
$arrlines = $lines.Split(' ')

foreach ($Server in $arrlines) {
  if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {         
    write-Host "$Server is alive and Pinging " -ForegroundColor Green
  } else {
Write-Warning "$Server seems dead not pinging"
  }  
}

Something like this:



end

No comments:

Post a Comment