Hi All,
I have a script which would collect some windows hardware information. I have list of servers in $filelist. and so, I have used
foreach ($computer in $filelist) {
write-host `n
write-host Processing server $computer -ForegroundColor yellow
$column = 1
if ((Test-Connection -computername $computer -Quiet) -eq $true) {
do something
} else {
write-host server not online.
}
to check this functionality, I have entered some not available, servers in the file and executed the script. Some non existing hostnames like abc, def etc.. when I execute my script with these hostnames, it should test connection, and as it fails, it should write to host saying it is not online. In the above code, DO SOMETHING code should not work. But in my case, it is going to all the steps, and it is throwing looooooooooot of errors on screen. Any way to fix this?
Chaitanya.