Bulk Add Users to Group Using Log on Name

I have found that the following windows command will add a user to a group in AD:

dsquery user -samid <logonname>|dsmod group "CN=<groupname>,CN=Builtin,DC=<domainprefix>,DC=<domainsuffix>" -addmbr

My question is how can I package this into some sort of script to take the logon names (samid) of many users a run them through this so that they are each added to my group?

  • Edited by S6D4G6 11 hours 43 minutes ago
January 20th, 2014 6:50pm

Use a batch file and a FOR /F command.

At a command prompt type: "for /?"

Look at the examples.

Free Windows Admin Tool Kit Click here and download it now
January 20th, 2014 6:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics