Skip navigation

JSI Tip 4568. How do I copy, or mass delete, domain group membership?


In tip 4509, we generated a file of a domain group's membership.

If you wish to copy this membership to a different group, or use it to delete the membership of the exported domain group, use GroupMaint.bat. The syntax is:

GroupMaint GroupName InputFileName \[/ADD | /DEL\]

Where:

GroupName is the domain group you are adding to, or deleting from.
InputFileName contains the list of domain users.
/ADD or ADD is the default action. If the parameter is ommitted, the InputFileName users wil be added to GroupName.
/DEL or DEL will delete the InputFileName users from GroupName.

GroupMaint.bat contains:

@echo off
setlocal
if \{%1\}

\{\} goto syntax if \{%2\}

\{\} goto syntax if not \{%4\}

\{\} goto syntax if \{%3\}

\{\} set type=/ADD&goto begin if /i "%3" EQU "/ADD" set type=/ADD&goto begin if /i "%3" EQU "ADD" set type=/ADD&goto begin if /i "%3" EQU "/DEL" set type=/DEL&goto begin if /i "%3" EQU "DEL" set type=/DEL&goto begin goto syntax :begin set grp=%1 set file=%2 if not exist %file% goto syntax for /f "Tokens=*" %%i in ('type %file%') do set name=%%i&call :parse endlocal goto :EOF :syntax @echo Syntax GroupMaint GroupName InputFileName \[/ADD ^| /DEL\] endlocal goto :EOF :parse net group %grp% "%name%" %type% /domain


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