New-ADUser - Automated User Object Creation in AD
# Import list of users from a CSV file into $userlist (two columns: firstname, lastname)$userlist=import-csv C:\users.csv
# Step through each item in the list
ForEach ($person in $userList) {
# Build username from the letter 'p', lastname, and then the first letter of firstname
$username="p"+$person.lastname+$person.firstname.substring(0,1)
# Create the displayname (firstname space lastname)
$displayname=$person.firstname+" "+$person.lastname
# Store the encrypted password so it can be created via the -accountPassword parameter in new-aduser
$encryptedpassword=convertto-securestring "enter_password_here" -asplaintext -force
# Create the user in Active Directory using the new-aduser cmdlet
New-aduser -GivenName $person.firstname -name $username.ToLower() -Surname $person.lastname -DisplayName $displayname -SamAccountName $username.tolower() -accountPassword $encryptedpassword -passwordneverexpires $True -path "OU=Test,OU=Users,OU=Contractors,DC=Billiton,DC=BHP" -Enabled $True -Description "generic test account"
}