List down all computer names in a Network
I want to list all computer names in the Domain. I have try with WMI but it return a error, "query invalid". Code as follows,
If you have any idea, pls let me know.
Thanks
Manjula
using System;
using System.Management;
class NetworkComputerTest
{
public static void Main()
{
try
{
ManagementObjectSearcher query = new
ManagementObjectSearcher("root\\cimv2", "Select * From Win32_NetworkConnection WHERE Domain= sscomp" ) ;
ManagementObjectCollection queryCollection = query.Get();
foreach( ManagementObject mobject in queryCollection )
{
string name = (string)mobject["Name"];
Console.WriteLine( "Name '{0}'", name);
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}