Please try this:
$computers = Get-Content -Path "ListOfComputerIP.txt"
foreach ($computer in $computers)
{
$ip = $computer.Split(" - ")[0]
if (Test-Connection $ip -Count 1 -ErrorAction SilentlyContinue){
Write-Host "$ip is up"
}
else{
Write-Host "$ip is down"
}
}
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten