Need Test connection output in the csv file

by Jun 13, 2013

Hi,

I am completely newbie to Powershell.

Just I am trying to ping multiple VMs using the scripts. I created a file with list of VMs

———————————————————————————————————–

$vms = Get-Content $file

foreach($vm in $vms)

{

if(Test-Connection -ComputerName $vm -Quiet)   

}

————————————————————-

From here how can i get the output in the form of Excel sheet as below.

VMName  Ping Status

VM1            Ok or Failed