How to "batch" create folders for Active Directory users' network drive?

This is how I add new users to my Active Directory server:

  1. Setup the OU's, Groups, etc in AD GUI
  2. Create a batch file to create new users (dsmod)
  3. Run that .bat file
  4. Create a batch file to reset the individual passwords to something unique (admod)
  5. Run that .bat file

Now I want to add something to the workflow, which I do not know how:

  • Create individual folders in a Local Drive named after each user (e.g. d:\sAMAccount)
  • Assign those folders to each respective user in Active Directory
  • Automatically Map Network Drive when the users login (assuming their PC's are in the Domain)

What's the best way to go about this?


in your server side batch:

  • create the folder,
  • create a share with a sAMAccountName based naming convention,
  • assign a 'mount my home share' login script to the new account

    md d:\%sAMAccountName%

    net share home-%sAMAccountName%$=d:\sAMAccountName /GRANT:%sAMAccountName,FULL /REMARK:"Home-Folder for %sAMAccountName%"

    dsquery user -samid %sAMAccountName% | dsmod user -loscr "\SomeDC\NETLOGON\mapHome.cmd"

the 'mapHome' script is the same script for all affected users it just contains:

net use h: \\FileServer\home-%USERNAME%$