Question : Script to Connect a home directory in Active Directory

I want to write a script (and I have no experience in doing this) to create a new user, so I don;t have to go into active directory and set it up (with the ultimate idea of having a script a delegate could use).  I have figured out how to make their directory.  I now want script their home directory and map it.  If in my batch file I put in
net user username /homedir:\\server\username$
It puts the path in the local directory.  I want the home folder in the connect section of AD, selecting G:\ and then tell it that g:\ should be \\server\username$.

How do I do that?

Answer : Script to Connect a home directory in Active Directory

Install adminpak.msi from %logonserver%\admin$\system32 and use the ds-commands like below. dsmod neads the userDN which can be piped from the dsquery-command.
dsquery user -samid | dsmod user -hmdir \\server\$ -hmdrv G:

As you want to create the user, you can set all the parameters directly with dsadd-command:
dsadd user -samid -upn @domain.com -fn -ln -display " " -hmdir \\server\$ -hmdrv G:

If you want to add the user to a group, you use the 'dsmod group'-command:
dsmod group -addmbr
or
dsquery group |dsmod group -addmbr

Use 'dsquery user /?', 'dsmod user /?' or 'dsadd user /?' to get help for the commands.
Random Solutions  
 
programming4us programming4us