title: How to export the result to .csv? with ServerName as first column and online/offline as second column
body: <p>I am trying to export the result of the powershell to csv with $server as the first column and online/offline as the second column. There are many column i want to define actually. I think this is a good start. Please let me know how to achieve this.</p>
  
  <pre><code>$ErrorActionPreference = 'SilentlyContinue'
  $ServerName = "TDL498", "TDL498123", "TDL498456"
  foreach ($Server in $ServerName)
  {
  
      if (test-Connection -ComputerName $Server -Count 2 -Quiet)
      {
  
          write-Host "$Server Online" -ForegroundColor Green 
      }
      else
      {
          Write-Host "$Server Offline"
  
      }
  } 
  </code></pre>