Password Never Expires CSV import

Dan560
Dan560 used Ask the Experts™
on
Hi,

I have succesfully created a CSV import into AD, however when I do the bulk import the user accounts all have "passowrd must be changed at next login" how do set this in my csv file so that it have the password never expires attribute enabled?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi!
CSV imports cannot assign passwords by design. :-(
The ususal answer to this question is to use VBScript to modify the users after they are created.

However, if you don't have time to learn VBScript there are a number of command line tools for manipulating AD objects.
dsquery                                             - finds objects in AD and returns their DN
dsadd dsget dsmod dsmove dsrm.   - takes the DN of an object and acts on it is some way.

Type "dsmod" at a command prompt to check it is available.
They should be on the server or can be downloaded from MS in one of the support packs.

You can add another column to your CSV spreadsheet to create a series of DSMod commands.
Copy this formula into each cell.

="dsmod user "&""""&C2&""""&" -pwd P@ssw0rd -mustchpwd  no"

This breaks down to -
"dsmod user "                                         -a string containing the first part of the command
""""                                                          -four quotes together. Puts a single quote in the result.
C2                                                           - the column containin the DN of each user
""""                                                          - another four quotes
" -pwd P@ssw0rd -mustchpwd  no"    - Pay dirt! Set the password and "Must change password" to No

This should endup with a column containing entries like this.
dsmod user "CN=Clark Kent,OU=Department,DC=Company,dc=com" -pwd P@ssw0rd -mustchpwd  no
dsmod user "CN=Peter Parker,OU=Department,DC=Company,dc=com" -pwd P@ssw0rd -mustchpwd  no
dsmod user "CN=Bing Crosby,OU=Department,DC=Company,dc=com" -pwd P@ssw0rd -mustchpwd  no

Copy the first one and paste it into a command prompt to check it works.
If so, copy the whole rest of the column and paste that into the command prompt.
It will rattle through the entire column.

:-)

Author

Commented:
Passwords can be assigned, my csv file allows this with no problem. I use the following attributes:
sAMAccountName userPrincipalName givenName displayName description password.
In the end I just manually modified the users by selecting them all and selecting the "password never expires option."
But I appreciate your answer.
You are of course correct. :-)
I was thinking of "User must change passwords" but apparently I only typed part of it. ;-)

I wondered if I could write an article on DSMod but there is an excelent one here already.

http://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/A_1724-Active-Directory-Bulk-updating-user-information-using-Excel.html?sfQueryTermInfo=1+30+dsmod

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial