
#Created By Alberto Igbinedion

<#This script pings servers listed in a CSV file called Clean_Failed.csv
...#>
#Check that Exchange Snap-in is added if not add it
$snaps = Get-PSSnapin
foreach($snap in $snaps){if($snap.name -eq "Microsoft.Exchange.Management.PowerShell.E2010"){$exflag = 1}}
if($exflag -ne 1){Add-PSSnapin -name Microsoft.Exchange.Management.PowerShell.E2010}

	$data = Import-Csv C:\Scripts\input\Cleanup_Failed.csv

#Defines the variables with the Trim statement to remove White Spaces (.Trim())
    foreach ($row in $data) {
    $Name = $row.Name.Trim()
	
	Test-Connection $Name | Out-File C:\scripts\PingResults.csv 

######OR####
######$Computers = Get-Content C:\scripts\PingResults.txt##########

#######Test-Connection $Computers | Out-File C:\scripts\PingResults2.csv########



	}