Creating Bulk Users

by brycspain at 2012-12-28 09:12:30

Not sure why this is so hard but I’m not having any luck creating 90 or so test accounts. Ive tried different versions of the password to meet complexity requirements but I have no idea why this won’t work. I’m logged into a DC with my domain admin privileges with the AD module imported. Any suggestions would be appreciated.

For($i = 10; $i -lt 101; $i++)
{
$UserNumber = $i + 1
$user = "Ctxtst"

New-ADUser $user$usernumber -accountPassword (ConvertTo-SecureString "CitrixM3" -AsPlainText -Force) -Enabled $True -server "mydc" -path "OU=CTX_Test,OU=Users,OU=Test,DC=mydomain,DC=Com"
}


These are the errors:

New-ADUser : Directory object not found
At line:5 char:5
+ New-ADUser $user$usernumber -accountPassword (ConvertTo-SecureString "Citrix ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=Ctxtst11,OU=...onhealth,DC=Com:String) [New-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.NewADUser

New-ADUser : Directory object not found
At line:5 char:5
+ New-ADUser $user$usernumber -accountPassword (ConvertTo-SecureString "Citrix ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=Ctxtst12,OU=...onhealth,DC=Com:String) [New-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.NewADUser

New-ADUser : Directory object not found
At line:5 char:5
+ New-ADUser $user$usernumber -accountPassword (ConvertTo-SecureString "Citrix ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=Ctxtst13,OU=...onhealth,DC=Com:String) [New-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.NewADUser
by nohandle at 2012-12-28 09:38:47
[quote="brycspain"]New-ADUser : Directory object not found[/quote]
Looks like the resulting LDAP path issue. Can you review if the path in the exception info is correct path.

To list it:
$error[0] | fl -force *
by brycspain at 2012-12-28 12:10:43
The path was identical however, I cut and pasted out of ADSIEdit and it worked. Thanks for pointing me in the right direction.
by nohandle at 2012-12-28 13:45:00
You are welcome. If the issue is solved please mark the thread as solved using the Solved button.