How to get a list of computer names in a domain using C #?
using System.DirectoryServices; public void PrintComputersInDomain (string domainName) { DirectoryEntry de = new DirectoryEntry ("LDAP://" + domainName); de.Children.SchemaFilter.Add ("computer"); foreach (DirectoryEntry c in de.Children) { Console.WriteLine (c.Name); } }
from http://msmvps.com/blogs/siva/archive/2008/01/25/enumerating-computers-in-a-domain.aspx
If you are in a Windows domain, you can run an LDAP query on the directory to cancel the list of machine accounts