title: Ping a list of host names and output the results to a csv in powershell
body: <p>I have a large list of hostnames I need to ping to see if they are up or down. I'm not really that great at scripting but I managed to figure this much out:</p>
  
  <pre><code>$names = Get-content "hnames.txt"
  
  foreach ($name in $names){
    if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
      Write-Host "$name is up" -ForegroundColor Green
    }
    else{
      Write-Host "$name is down" -ForegroundColor Red
    }
  }
  </code></pre>
  
  <p>This gets me what I need but i now need to write out these results to a csv file and i have no idea how to do that.</p>
  
  <p>Please Help!</p>