I am new to systems admin and am taking a class. i am supposed to create a script that creates 100 new AD users. I’ve tried running it and I get an error “New-aduser : The name provided is not a properly formed account name” I tried soooo many different things. Please help me with any help possible. I’ve included a portion of what is actually a .csv file. and my script. Any help or tips will be greatly appreciated. Thank you.
First Name Initials Last Name Full Name User logon name password
aarona a curtis aarona curtis aarona.curtis Silverio0716
aaronb b curtis aaronb curtis aaronb.curtis Silverio0716
Import-Module active directory
$hundred = Import-csv c:\Users\Administrator.CURTISFAMINC\Documents\finalstep.csv
foreach ($user in $hundred)
{
$username = $user.username
$password = $user.password
$firstname = $user.fname
$lastname = $user.lname
new-aduser -samaccountname $username -name "$firstname $lastname" -givenname $firstname -surname $lastname -enabled $true -displayname "$lastname, $firstname" -scriptpath "C:\Users\Administrator.CURTISFAMINC\Documents\hundred" -accountpassword (convertto-securestring $password -asplaintext -force)
}