Downloads
94471.zip

In “Copy Group Memberships the Easy Way” (August 2006, InstantDoc ID 50424), I provided a batch-file script—CopyGroup.bat—which copies Active Directory (AD) group memberships from one group to another in Exchange Server 2003 and Exchange 2000 Server. I've written a follow-up script—CopyUsersGroups.bat in Listing 1—that you can use to easily copy group membership from one user to another. (Note that some code in the listing wraps to multiple lines because of space constraints.) This solution will save you a lot of time when you need to give a new user the same group membership as another existing user in the company. You can use CopyUsersGroups.bat to copy an account, including the group memberships when an account is created—a capability that's especially useful when you need to copy the group memberships after the account has been created.

Like CopyGroup.bat, CopyUsersGroups.bat uses the Dsquery, Dsget, and Dsmod utilities to find and copy group memberships. Windows Server 2003 includes these three tools. Alternatively, you can install them from the Windows Server 2003 Administration Tools Pack (adminpak.msi).

In addition to CopyUsersGroups .bat, the solution requires an .ini file— utils.ini in Figure 1—which you need to customize. In utils.ini, substitute the path to your Dsquery, Dsget, and Dsmod utilities for sourcedir and the name of your own domain controller (DC) for DomainControllerName. CopyUsersGroups.bat and utils.ini must be in the same folder (e.g., C:\admin). Modify your PATH variable to include this folder.

To display the command's Help screen, in a command-shell window, enter the script name without any parameters. To run the script, enter the command as follows:

CopyUsersGroups.bat
  FromUser ToUser

(Be sure to type the actual command on one line.) Replace the FromUser and ToUser parameters with the appropriate AD sAMAccountName attributes, which are displayed when you invoke the script without parameters.

—Frank Houbak Kristiansen