Scripts Thread, DSQuery with DSMod in Coding and Web Development; I am trying to create a script that creates users using csvde, then using dsquery and dsmod to enable their ...
1. DSQuery with DSMod

I am trying to create a script that creates users using csvde, then using dsquery and dsmod to enable their accounts, set the password and set their homedrive with homedirectory. The problem I am hitting is with the homedir, it needs to end with the current user I am editing, if I use the %Username% variable it uses the currently connected user and sets them all to that....
Is there another way of using dsget or dsquery to pipe the username its editing? This is what I have so far.
Code:
::Location of the csv file with the user info
SET filename="\\path\to\file\file.csv"

::Location to create users, you should have this info in the DN section of the csv file without the username
SET location="OU=Import,OU=Students,OU=Accounts,DC=domain,DC=local"

::Home directory
SET homedir=\\path\to\homedir\

csvde -f %filename% -i -k
PAUSE
Dsquery user %location% | Dsmod user -pwd %password% -hmdrv h: -hmdir %homedir%%username% -disabled no
PAUSE

2. Never mind, fixed it. If its useful, here is the fix;
Had to use $username$ and not %username%
Code:
::Location of the csv file with the user info
SET filename="\\path\to\file\file.csv"

::Location to create users, you should have this info in the DN section of the csv file without the username
SET location="OU=Import,OU=Students,OU=Accounts,DC=domain,DC=local"

::Home directory
SET homedir=\\path\to\homedir\

csvde -f %filename% -i -k
PAUSE
Dsquery user %location% | Dsmod user -pwd %password% -hmdrv h: -hmdir %homedir%$username$ -disabled no
PAUSE

SHARE: