PingTest:
$names = get-content "C:\hostnames.txt"
foreach ($names in $names){
if (Test-Connection -ComputerName $names Count 1 -ErrorAction SilentlyContinue){
write-host "$names is up" -ForegroundColor Green
}
else{
write-host "$names is down" -ForegroundColor Red
}
}