title: Getting quick Server Ping Results in Powershell
body: <p>I have written below PowerShell script to get the ping results of server and it also generates the log for the same. My script works fine, also generates log but it take so much time as there are many servers. Is there any way I can quickly get the results. I have tried start-job but that generates error.</p>
  
  <pre><code>   $logpath = $logpath +"\" +$Logname
  
      Function Log($txt)
      {
           if (! (Test-Path $logpath)) {
                  New-Item $logpath |Out-Null
           }
  
           $date = Get-Date -Format "dd_MMM_yyyy_hh:mm:ss - "
           $txt1 = ($date + $txt)
  
           Add-Content "$logpath"  "$txt1"
           Add-Content "$logpath" " "
       }
       $ServerDetails=import-csv $Servercsv
  
       foreach($servertest in $ServerDetails)
       {
          if((Test-Connection -ComputerName $servertest.servers -Count 2))
          {
            Log("'" + $servertest.servers + "' Successfully started operation")
            Write-Host "Started Operation Successfully"
          }
          if(!(Test-Connection -ComputerName $servertest.servers -Count 2))
           {
             Log("'" + $servertest.servers + "'Servers are not pinging")
             Write-Host "Servers are not pinging"
  
           }
       } 
  </code></pre>