I’m trying to do a simple query off a long list of computers if they’re online. I’m using test-function and it works, but rather than give me the response back per machine it seems to be coming back as the entire group of computers in 1 line, then ending with online.
Not sure exactly what i’m missing but i want to then add certain commands if a machine is online.
If anyone could provide me information on what i’m missing i’d appreciate it.
#Import Computer list from file $Computers = Get-Content -path 'L:\scripts\complist.csv' #Check to see if each computer is online ForEach ($computer in $Computers) { if (Test-connection -Computername $computer -BufferSize 16 -Count 2 -Quiet) { Write-Host $Computers is online } }