Powershell – New-ADUser ADException NotSpecified

active-directorypowershell

I am receiving an error when I run this powershell command to add a new user:

PS > New-ADUser -Name "user1" -GivenName "test" -Surname "User" -Path "ou=Users"

The error returned when run is:

CategoryInfo : NotSpecified: (CN=user1,ou=Users:String) [New-ADUser], ADException

If I take of the "Path" parameter the user is added, but not added to an OU.

Best Answer

"ou=users" is not sufficient. You have to supply the full distinguished name of the OU you want the new account to be created in. It's also incorrect if you're talking about the Users container at the base of the domain, which is not an OU, but a container. Here are some examples.

CN=Users,DC=domain,DC=com

OU=MyOU,DC=domain,DC=com

OU=SubOU,OU=MyOU,DC=subdomain,DC=domain,DC=com

Get-ADObject