Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Ping bulk computers

$
0
0

1.Type and identifier are both required in a foreach statement

2.The name 'lines' does not exist in the current context

public void Main()
        {
            try
            {
               
                using (StreamReader sr = new StreamReader("g:\\computer3.txt"))
                {
                    String line = sr.ReadToEnd().ToString();
                  
                    foreach (line in lines)
                    {
                    string ipd;
                    IPHostEntry hostname2 = Dns.GetHostEntry(line);
                    IPAddress[] ip = hostname2.AddressList;
                    ipd = ip[0].ToString();
                    ResultBlock.Text = ipd;
                    }
                }

            }
            catch (Exception ex)
            {
                ResultBlock.Text = "Could not read the file";
            }


        }


Support@Mytechnet.me


Viewing all articles
Browse latest Browse all 21975

Trending Articles