How can i increase lenght of -Name option of New-ADUser command

Ismail OZDEMIR 21 Reputation points
2022-07-19T10:45:28.517+00:00

Hello,

First of all, sorry for my bad english, i do not use translate services.

I wan't to use a script to import users in Active Directory from CSV file.

But i cannot import some users with this script, because the lenght of their name is higher than 20 characters and the command New-ADUser and his option -Name (for some reason) do not allow that.

My question is how can i increase the lenght for this option.

Thanks for your help.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Limitless Technology 39,931 Reputation points
    2022-07-20T10:39:45.96+00:00

    Hello

    Thank you for your question and reaching out. I can understand you are having issues related to character limit in AD

    If you are using server 2012 R2 you can only set the display name to 20 char however the login name can be up to 64 char (I think) using "-UserPrincipalName"

    You can have a Name that exceeds 20 characters, but not a sAMAccountName.

    Reference :
    https://learn.microsoft.com/en-us/windows/win32/adschema/a-samaccountname?redirectedfrom=MSDN

    https://social.technet.microsoft.com/Forums/windows/en-US/ca4b06d5-f629-4906-bc91-4f02d2c43f15/powershell-script-newaduser-name-properties-too-long?forum=ITCG#:~:text=This%20property%20can%20only%20be,up%20to%20256%20characters%20long

    -------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 47,516 Reputation points
    2022-07-19T10:59:43.137+00:00

    this command (for some reason) do not allow that.

    And now we have to guess which command or script you use?
    20 characters have been a limitation in Win NT 4.0 and previous version.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.