Hi everyone I have a script to check to see if it can ping a list of IPs. If it cannot reach 1 it stores it in an array. The problem is if only 1 IP is stored in the array it treats each char as an element of that array.
$psr = $PSScriptRoot
$a = Get-Content $psr\list.txt
$machines = @()
for($i=0;$i -lt $a.length;$i++){
$key = $a[$i]
$info = @()
$info = -split $key
$machines = $info[0]
}
#Start-Sleep -Seconds 60
for($j=0;$j -lt $machines.length;$j++){
if(!(Test-Connection -ComputerName $machines[$j] -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host $machines[$j]
}else{
Write-Host "All machines are awake"
}
}It happens in the second for loop list is just a snippet of the code. How can I write to host the full IP as 1 element?
Thanks