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 Monday, January 20, 2014 11:49 PM
January 21st, 2014 2:48am

@echo off
setlocal

set pwd= password

for /f  %%a in (users.txt) do (

dsadd user "CN=%%a,OU=<OU> ,DC=<DC>" -pwd %pwd%

)

You can add users in users.txt

I hope this works

 
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 12:48am

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

Other recent topics Other recent topics