Imports System.DirectoryServices
Dim de As New DirectoryEntry("WinNT://TEST") ' Put the name of yourworkgroup/domain here
Dim computer As DirectoryEntry
For Each computer In de.Children
ListBox1.Items.Add(computer.Name)
Next
Imports System.DirectoryServices
Dim objDE As DirectoryEntry
Dim MyWorkGroupName As String = "Mshome" '-- Change to your workgroup name
Dim strPath As String = "WinNT://" & MyWorkgroupName
objDE = New DirectoryEntry(strPath) '-- Create a new DirectoryEntry with the given path.
Dim objChildDE As DirectoryEntry
For Each objChildDE In objDE.Children
Console.WriteLine(objChildDE.Path)
Next objChildDE
Dim compname As String
Dim strPath As String = "WinNT://" & System.Environment.UserDomainName
Dim mySearcher As DirectorySearcher = New DirectorySearcher(strPath)
mySearcher.Filter = ("(objectClass=computer)") ' <-----------------Here is the filter! Just computers
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
compname = Right(resEnt.GetDirectoryEntry().Name.ToString(), Len(resEnt.GetDirectoryEntry().Name.ToString())-3)
Console.WriteLine(compname)
Next
Here is a function to find the ip of those machine names:
Function GetIPAddress(ByVal hostname As String) As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
Try
With System.Net.Dns.GetHostByName(hostname)
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
End With
GetIPAddress = sAddr
Catch
GetIPAddress = ""
End Try
End Function