How large is your organization? If it is somewhat small, you can use LDIFDE.EXE to query AD for all user accounts and then manually count the list. If you would have too many to count, you will probably want to write a script and use VBScript and ADSI.
Try this. I didn't write it and I can't find who did but it is quite useful.
You'll just need to change the domain name and domain controller lookup entries.
Neill
'This script finds all groups in an AD, counts all members of each group
' and writes group names and count into a file
'*** will only count users in a group, will not count nested groups ****
Const ForAppending = 8
strSoeg = "SELECT Name FROM 'LDAP://dc=domain, dc=COM' " & _
"WHERE objectCategory='group'" ' define domain to search
strDC = "dc???" ' define Domain controler to lookup groups
strPath = "c:\groups.csv" ' define file to write info
'Prepare file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(strPath, ForAppending, True)
'Prepare for AD search
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 10
objCommand.CommandText = strSoeg
Set objRecordSet = objCommand.Execute
objRecordSet.Movefirst
Do until objRecordSet.EOF
intMembers = 0
'find group name
strADsPath = objRecordSet.Fields("Name").value
' clean up group name
strGroup = rtrim(ltrim(strADsPath))
'prepare to access group strGroup
Set objGroupe = GetObject("WinNT://" & strDC & "/" & strGroup & ",group")
'count members of group strGroup
For Each objMember in objGroupe.Members
intMembers = intMembers + 1
Next
'write groupname and count to file
objTextFile.WriteLine (strGroup & ";" & intMembers )
set objGroupe = nothing
objRecordSet.MoveNext
loop
'clean up
set objRecordSet = nothing
set objGroupe = nothing
set objTextFile = nothing
set objConnection = nothing
set objCommand = nothing
set objFSO = nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.