$computers = Get-Content "C:\computers.txt"
$offline =@()
foreach ($computer in $computers)
{
if (Test-Connection $computer -Count 3 -ea 0) {
Stop-Computer -ComputerName $computers
}
else {
$offline+= "$computer not reachable"
}}
$offline =@()
foreach ($computer in $computers)
{
if (Test-Connection $computer -Count 3 -ea 0) {
Stop-Computer -ComputerName $computers
}
else {
$offline+= "$computer not reachable"
}}