Loading...
 

Greg`s Tech blog

Updating user accounts with DSMOD

Thursday 07 of April, 2005
We had to set the passwords for a bunch of accounts. DSMOD seemed appropriate since we had a list of DNs.

Here's what I did.
I saved the file as a CSV then replaced the commas delimiting the fields with colons. Using comma as the delim didn't work since DNs have commas.

Then the following command did the trick:
for /f "delims=: tokens=1-3" %a in (ETSNT60UsersToSetPasswords2.csv) do dsmod user %a -pwd %c

The for /f loops through the file specified in 'in (...)

The delims=: tells for that every colon delimits the next field

The tokens tells for how many items to pass once it has split the input line based on the delim

The %a is the name of the first token. Inour command %a %b & %c was set with DN, samaccoutname and password. The samaccount name was not need so the followin g command would have worked:

for /f "delims=: tokens=1,3" %a in (ETSNT60UsersToSetPasswords2.csv) do dsmod user %a -pwd %c
Note the change in token to pass just the first & 3rd token (DN & pwd).

\\Greg