Skip navigation

JSI Tip 8240. What Active Directory groups exist that are not enumerated by the 'net group /domain' command?

I have scripted NUMGroups.bat to return a list of Active Directory groups that are NOT enumerated by the net group /domain command.

The syntax for using is NUMGroups.bat is:

NUMGroups

The output is displayed on the console, but you could pipe it to a file using:

NUMGroups>FileName

NOTE: NUMGroups.bat uses Groups.bat and the Active Directory Command-Line Tools.

NUMGroups.bat contains:

@echo off
setlocal
if exist "%TEMP%\domaingroups.tmp" del /q "%TEMP%\domaingroups.tmp"
for /f "Tokens=1*" %%f in ('groups D') do (
 @echo %%g>>"%TEMP%\domaingroups.tmp"
)
for /f "Tokens=*" %%g in ('dsquery group -o rdn') do (
 call :look %%g
)
del /q "%TEMP%\domaingroups.tmp"
endlocal
goto :EOF
:look
set grp=%1
set grp=%grp:"=%
for /f "Tokens=*" %%f in ('@echo %grp%^|findstr /i /V /L /G:"%TEMP%\domaingroups.tmp"') do (
 @echo "%%f"
)



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish