実行結果
PS > .\hoge.ps1 .\hosts.txt
host1 1
host2 0
host3 1
hoge.ps1
Param($file)
$hosts = Get-Content $file
$count = 3
$timeout = 3
foreach ($h in $hosts) {
$result = Test-Connection $h -TimeoutSeconds $timeout -Count $count -Quiet
Write-Output "$h $($result -as [int])"
}