PowerTip: Create a New User in Active Directory with PowerShell

Summary: Use the Active Directory module to create a user with Windows PowerShell.
Hey, Scripting Guy! Question How can I create a user in Active Directory with PowerShell?
Hey, Scripting Guy! Answer In Windows Server 2012 R2 or Windows Server 2008 R2, use the New-ADUser cmdlet.
To create a new user named “Doctor Scripto” in Active Directory:
NEW-ADUSER doctor.scripto –Givenname Doctor –Surname Scripto

Comments (10)

  1. Chen V says:

    New-ADUser Chendrayan -OtherAttributes @{title="SharePoint 2010 Admin";mail="something@domain.com"}

    Cool – PowerShell Rocks

  2. Raj says:

    how to start writing powershell scripts

  3. ndl says:

    Raj, 1. Open Notepad 2. Write 3. Save 4. Run 5. ????????? 6. PROFIT

  4. shawn says:

    What about the Password?

  5. rik says:

    Raj, use the powershell ISE (included in .net framework). open start, type in “ISE” and you should get it. write a script and press F5 to run it.

  6. Mike H. says:

    Quick question..I have server 2012 (not R2). I tried this on my server, no luck. Is there a big difference between 2012 and 2012 R2? If so, how can I create new user in Powershell in 2012? I’ve tried everything I’ve read..thanks

  7. Saravanan Deivasigamani says:

    Hi, please tell how to set the default password and password much change on next logon using the same script

  8. Chris says:

    to set the password use
    -AccountPassword (ConvertTo-SecureString "PASSWORD1" -AsPlainText -force)

    when the account is created it will be created as disabled, to enable as part of the creation
    -enabled $true

    -ChangePasswordAtLogon $true (I believe this is what you are looking for for change password at next logon)

  9. jasper says:

    I don’t see anywhere telling you that you need to;

    Import-Module ActiveDirectory

    And have at least ADLWS role installed for the comlets to be available

Skip to main content