Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I create a domain user account and set the default password in PowerShell from a CSV?

Note that I know how to do this, I'm writing this as a self-answered question to share this knowledge. If anyone has a better answer, please chime in!

share|improve this question
up vote 2 down vote accepted

This answer assumes that you have a CSV with two columns that have the headings: username and password.

It doesn't take make other attributes, such as firstname, lastname, manager, department, etc. They can all be added and are outlined in the get-help new-aduser -full command.

This is the bare minimum that needs to be done to automate account creation. In production, you'll probably want to force password change on first logon as well as setting many other attributes.

Import-Module ActiveDirectory

Import-CSV c:\users\marra\desktop\userlist.csv | ForEach-Object {
    $name = $_.username                                               
    $pw = $_.password 
    $ss = ConvertTo-SecureString -string $pw -asPlainText -force        

    New-ADUser $name -SamAccountName $name -AccountPassword $ss -Path "OU=MyUserOU,DC=mydomain,dc=com" -Enabled $TRUE        
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.