I have scripted GetGroups.vbs to return all the groups in your domain, returning the following in semi-colon separated format:



<b>DistinguishedName</b> is the distinguished name of the group.

<b>sAMAccountName</b>    is the NetBIOS (Pre-Windows 2000) name of the group.

<b>Scope</b>             is the group scope:
                         <b>B</b>   for a <b>Built-in</b> group.
                         <b>L</b>   for a Domain Local group.
                         <b>G</b>   for a Global group.
                         <b>U</b>   for a Universal group.

<b>SecDst</b>            is the group type:
                         <b>S</b>   for a security group.
                         <b>D</b>   for a distribution group.
GetGroups.vbs contains:
On Error Resume Next
Dim objConnection, objCommand, objRootDSE, strDNSDomain
Dim strFilter, strQuery, objRecordSet, gt
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
'Get domain
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
'Define the filter elements
strFilter = "(&(objectCategory=group))"
'List all attributes you will require
strAttributes = "distinguishedName,sAMAccountName,groupType"
'compose query
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99999
objCommand.Properties("Timeout") = 300
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
    strDN = objRecordSet.Fields("distinguishedName")
    strSA = objRecordSet.Fields("sAMAccountName")
    gt = objRecordSet.Fields("groupType")
    if (gt ANd &h01)  0 then
    Scope = "B"
    ElseIf (gt And &h02)  0 Then
    Scope = "G"
    ElseIf (gt And &h04)  0 Then
    Scope = "L"
    ElseIf (gt And &h08)  0 Then
    Scope = "U"
    End If
    If (gt And &h80000000)  0 Then
     SecDst = "S"
     SecDst = "D"
    End If
    Wscript.Echo <div class="Contentquote"><center>" & strDN & </center></div>;<div class="Contentquote"><center> & strSA & </center></div>;<div class="Contentquote"><center> & Scope & </center></div>;<div class="Contentquote"><center> & SecDst &</center></div>"
' Clean up.
Set objConnection = Nothing
Set objCommand = Nothing
Set objRootDSE = Nothing
Set objRecordSet = Nothing