New-ADUser : The object name has bad syntax RRS feed

  • Frage

  • This is my code, I just started learning powershell and I want to create new user at the location of the code, but I always get the same error, also, can someone explain what the "DC" is and what should I declare in it?

    Import-Module ActiveDirectory
    New-ADUser -Name "Usuário Teste" -SamAccountName uteste 
    -Path "OU=Centralized\BR\Account\User DC=aldautomotive DC=com"


    New-ADUser : The object name has bad syntax
    At line:2 char:1
    + New-ADUser -Name "Usuário Teste" -SamAccountName uteste -Path "OU=Cen ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (CN=Usuário Test...tomotive DC=com:String) [New-ADUser], ADException
        + FullyQualifiedErrorId : ActiveDirectoryServer:8335,Microsoft.ActiveDirectory.Management.Commands.NewADUser

    Dienstag, 21. Januar 2020 15:13

Alle Antworten

  • Hi,

    Use commas in the OU path, like this:

    Import-Module ActiveDirectory
    New-ADUser -Name "Usuário Teste" -SamAccountName uteste -Path "OU=Centralized\BR\Account\User,DC=aldautomotive,DC=com"

    Verify that the container or OU is also valid.

    You can use the Get-Help command to give examples and useful help, here's an example from the Get-Help New-ADUser command:

    New-ADUser -SamAccountName "glenjohn"  -GivenName "Glen" -Surname "John" -DisplayName "Glen John" -Path 'CN=Users,DC=fabrikam,DC=
        local' -OtherAttributes @{'msDS-PhoneticDisplayName'="GlenJohn"}

    Best regards,

    Blog: LinkedIn:

    • Als Antwort vorgeschlagen Stoyan ChalakovMVP Dienstag, 21. Januar 2020 16:11
    • Nicht als Antwort vorgeschlagen jrvModerator Dienstag, 21. Januar 2020 18:33
    Dienstag, 21. Januar 2020 15:26
  • You need to specify the full Distinguished Name of the OU (or container). My guess is that the Path should be:

    -Path "ou=User,ou=Account,ou=BR,ou=Centralized,dc=aldautomotive,dc=com"

    Also, the value for sAMAccountName should be quoted. Otherwise, the value will be assumed to be a variable or function, instead of a string.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Als Antwort vorgeschlagen jrvModerator Dienstag, 21. Januar 2020 18:33
    Dienstag, 21. Januar 2020 16:28
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Montag, 27. Januar 2020 07:38