The below is a great little VBS script to find all empty Active Directory groups in the current domain.


cscript c:\Find_Empty_AD_Groups.vbs //nologo

The empty AD groups will be listed in your command prompt window.

The Script

'Define Constants
Const ADS_SCOPE_SUBTREE = 2 ' Search target object and all sub levels
'Set Variables
DQ = Chr(34) 'Double Quote
'Create Objects
Set objShell = CreateObject("Wscript.Shell")
'Verifies script was run using CSCRIPT, and if not relauches it using CSCRIPT
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then
	objShell.Popup "Launched using wscript. Relaunching...", 5, "WSCRIPT"
	objShell.Run "cmd.exe /k " & WScript.Path & "\cscript.exe //NOLOGO " & _
	DQ & WScript.scriptFullName & DQ, 1, False
	WScript.Quit 0
End If
'Construct an ADsPath to the Current Domain with rootDSE
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")
'Connect to Active Directory
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") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT ADsPath,cn,member FROM '" & strADsPath & _
"'" & " WHERE objectClass='group'"
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
	WScript.echo "Error, no groups found"
	WScript.Echo "List of empty groups"
	WScript.Echo "============================================================="
	Do Until objRecordSet.EOF
		strGroupName = objRecordSet.Fields("ADsPath").Value
		strCN = objRecordSet.Fields("cn").Value
		arrMembers = objRecordSet.Fields("member").Value
		If IsNull(arrMembers) Then
			'The group has no members
			'Show the Common name
			WScript.Echo strCN
			'To show the Distinguished name
			'WScript.Echo strGroupName
		End If
End If
WScript.Echo "Script has finished"

Alternative PowerShell Method

If you would prefer to use PowerShell take a look at the below link for an alternative method.