Jump to content

Recommended Posts

Posted (edited)

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.

::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\

::User password
SET password="password"

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

Edited by wiggum123
Posted

Never mind, fixed it. If its useful, here is the fix;

Had to use $username$ and not %username%


::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\

::User password
SET password="password"

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...