• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • PKI Training
  • OpenSSL
  • Keytool
  • PKI Tools
    • Apereo CAS
    • SAML
    • OpenID Connect
  • Get expert help

PowerShell Create AD Users

January 4, 2024 by Mister PKI Leave a Comment

This article will demonstrate how to with PowerShell create AD users. The examples provided assume you have permission to create new users in Active Directory. Rather than use ADUC (Active Directory Users and Computers), you can use PowerShell to create and automate account creation.

If not already imported, the Active Directory Module must first be imported to run the New-ADUser command.

Import-Module ActiveDirectory

Create new AD user

To create a new user with the PowerShell New-ADUser cmdlet, run the following command. In this example, many common options are included.

New-ADUser `
    -Name "Test User" `
    -GivenName "Test" `
    -Surname "User" `
    -SamAccountName "testuser" `
    -AccountPassword (Read-Host -AsSecureString "Input User Password") `
    -ChangePasswordAtLogon $True `
    -Company "Example Company" `
    -Title "Admininstrator" `
    -State "Virginia" `
    -City "Richmond" `
    -Description "Test Account" `
    -EmployeeNumber "123456789" `
    -Department "Employees" `
    -DisplayName "Test User" `
    -Country "US" `
    -PostalCode "12345" `
    -Enabled $True

Here are the options to the New-ADUser cmdlet described in detail.

  • Name: The full name of the user
  • GivenName: The first name of the user
  • Surname: The last name of the user
  • SamAccountName: The username
  • AccountPassword: The password to be read from the console input as not to be in the history in plain text. This option is how to use PowerShell to create a user with a password.
  • ChangePasswordAtLogon: Requires the user to set their own password the first time they log in
  • Company: The company the user works for
  • Title: The users job title
  • State: The state the user lives or works in
  • City: The city the user lives or works in
  • Description: User account description
  • EmployeeNumber: A unique identifier usually different than the SamAccountNumber, possible defined in an upstream ERP system
  • Department: The department the user works in
  • DisplayName: The preferred name of the user. Could be a nickname
  • Country: The country the user lives or works in
  • PostalCode: The zip code the user lives or works in
  • Enabled: Whether or not the user account is enabled upon creation

PowerShell Create AD User in a specific OU

To create a new AD user in a specific OU, use the -Path option.

New-ADUser `
    -Name "Test User" `
    -GivenName "Test" `
    -Surname "User" `
    -SamAccountName "testuser" `
    -AccountPassword (Read-Host -AsSecureString "Input User Password") `
    -Path "OU=Users,DC=example,DC=com"
    -Enabled $True

Create AD Users from CSV with PowerShell

To bulk create users from a flat csv file, import the users into a variable and loop through it to create the users. Make sure the order and header value in the csv is the same as used in the New-ADUser cmdlet.

$users = Import-Csv -Path users.csv
$users | ForEach-Object {
    New-ADUser `
        -Name $($_.FirstName + " " + $_.LastName) `
        -GivenName $_.FirstName `
        -Surname $_.LastName `
        -Department $_.Department `
        -UserPrincipalName $_.UserPrincipalName `
        -SamAccountName $_.SamAccountName `
        -AccountPassword $(ConvertTo-SecureString $_.Password -AsPlainText -Force) `
        -Enabled $True
}

Conclusion

This article has demonstrated how to with PowerShell create AD users and documented the common options included in the New-ADUser cmdlet.

To view the new user, use the Get-ADUser command. For example:

Get-ADUser -Identity testuser

If you have any questions or would like to see additional examples leave us a comment.

If you found this article helpful, check out more of our content.

active directory,  Identity Management,  powershell

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

PKI for DevOps Engineers – Free Training Series

PKI for DevOps Training Hub

Lesson 1 – How TLS and PKI Work

Lesson 2 – Understanding X.509 Certificates

Lesson 3 – Certificate Chains Explained

Lesson 4 – Debug TLS with OpenSSL

Lesson 5 – Verify Certificate Chains

Lesson 6 – Creating CSRs with OpenSSL

Lesson 7 – Working with PKCS12 Certificates

Lesson 8 – Java Keystores and keytool

Lesson 9 – Certificate Expiration Monitoring

Lesson 10 – Automating Certificate Renewal

Lesson 11 – Common TLS Errors

Lesson 12 – PKI Architecture for DevOps

Recent Posts

  • Apache mod_auth_cas: Protect Web Applications with Apereo CAS and Docker
  • Apache mod_auth_mellon: Configure SAML SSO & Docker
  • Configure OpenID Connect (OIDC) in Apereo CAS 7.3 and 8
  • Certificate Ownership Is an Operating Model Problem, Not a Tooling Problem
  • OpenSSL dgst: Create Checksums and Verify Digital Signatures

Footer

  • Twitter
  • YouTube
Mister PKI

Practical security engineering for the systems that establish trust.

Learn OpenSSL Keytool Free training
Work together PKI consulting CAS consulting Sponsored contributions
Site About Support Mister PKI Cookie policy Search
© 2026 Mister PKI Secure systems. Clear guidance.