Which Domain Groups Have No Members?

By | 2006-09-25

Using the Active Directory command-line tools, I have scripted NoMembers.bat to display the distinguished name of all domain groups that have no members.

The syntax for using NoMembers.bat is:

NoMembers

NoMembers.bat contains:

@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "Tokens=*" %%a in ('dsquery group') do (
call :quiet %%a >nul 2>&1
if "!mbr!" EQU "N" @echo %%a
)
endlocal
goto :EOF
:quiet
set mbr=N
for /f "Tokens=*" %%m in ('dsget group %1 -members') do (
set mbr=Y
)
Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.