Server Search in AD

  • Thread starter Thread starter Rick
  • Start date Start date
Rick said:
Not knowing the server names, how would I do a search for all servers
in ADUC?

I would use this ADO query in Filter Options, create custom filer, advanced:

(&(objectCategory=computer)(operatingSystem=*server*))

There may be other ways.
 
Rick said:
Thank Richard, wouldl you be able to tell me how to find other server
roles? DNS, SQL etc.

In VBScript I locate Domain Controllers, but the method doesn't seem like
one that can be distilled into one query. A sample VBScript program is
linked here:

http://www.rlmueller.net/Enumerate DCs.htm

WMI provides a way to determine the role of any computer object -
workstation, member server, DC. A sample program to find the role of all
computer objects in the domain is linked here:

http://www.rlmueller.net/ComputerRole.htm

You would have to use WMI to look for the DNS service on a machine to
determine if it is a DNS server. A quick program to list all services on a
computer would be:

=======================
Option Explicit
Dim objServices, colObjectSet, objObject, strComputer

strComputer = "MyMachine"

Set objServices = GetObject("winmgmts:\\" & strComputer)
Set colObjectSet = objServices.InstancesOf("Win32_Service")
For Each objObject In colObjectSet
Wscript.Echo "Display Name: " & objObject.displayName _
& vbCrLf & " -- State: " & objObject.State _
& vbCrLf & " -- Start Mode: " & objObject.StartMode
Next
=======================

Some service display names are "DHCP Client", "DHCP Server", "DNS Server",
"MSSQLSERVER", and "Windows Internet Name Service (WINS)". You could code a
VBScript program to similar to ComputerRole.vbs linked above that use ADO to
retrieve all computer objects, connects to each with WMI, and uses code
similar to above to find those with DCHP, DNS, SQL Server, WINS, or whatever
other service you like.
 
You can locate a DC using an LDAP query by searching for the primary group.
By default, a DC has a primary group with the well-known RID of 516.
Computers and servers have a default PG RID of 515.
 
Back
Top