[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

Using ADMod to import users into groups

I have been playing with using ADMod from JoeWare to import usernames into specifics groups.

I have the usernames as well as the groups that the need to be assigned to.

I could have the usernames in one file and the ad groups that the need to be assigned to in another file.

The other option is to have the username and group that the need assigned to on one line seprated by a comma.

Any good suggestions on how to do this using AdMod or should I look to code or re-code a script to do this?
  • 3
  • 2
2 Solutions
You could use DSMOD to do that:

DSquery user domainroot -name username | dsmod group "securitygroup,OU=GROUPS,DC=domain,DC=LOCAL" -addmbr

If you have the users and groups in a comma separated file you can use any editor (or excel) to add the DSQuery and dsmod parts
wrkstatAuthor Commented:
I have a file with the usernames (not DN) and the groups that each of these users needs to be put in.

Something that looks like this -



What would be the best way to import this into AD?

Edit your file:

At the beginning of each line add "DSquery user domainroot -name "
Replace "," with  "| dsmod group "
At the end of each line add ",OU=GROUPS,DC=domain,DC=LOCAL" -addmbr" (depending on you domain name and the location of the groups

So the first line reads:

DSquery user domainroot -name doej | dsmod group accounting,OU=GROUPS,DC=domain,DC=LOCAL -addmbr
wrkstatAuthor Commented:
I could not get that working. Had to modify the command to look like this -

dsquery user -samid doej|dsmod group "cn=accounting-W,OU=Groups,DC=domain,DC=com" -addmbr

This seems to work when changed as above.

wrkstatAuthor Commented:
The command specified by deroode didn't work, but after working with his concept I was able to get the command working after changing a few things to get the format right.

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now