New-ADUser
Use New-ADUser to create an Active Directory user account with identity attributes like -Name, -SamAccountName, -UserPrincipalName, and -AccountPassword.
Documentation: Microsoft Learn — New-ADUser
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
New-ADUser [-Name] <String> [-SamAccountName <String>] [-UserPrincipalName <String>] [-AccountPassword <SecureString>] [-Enabled <Boolean>] [-Path <String>] [-GivenName <String>] [-Surname <String>] [-WhatIf] [<CommonParameters>]- Stage 1New-ADUser
-Name -SamAccountName -UserPrincipalName -AccountPassword -Enabled -Path -GivenName -Surname -WhatIf
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
New-ADUser with a secure password
Show reference output
Sample output · fictional data, shaped like the real thing
Name SamAccountName UserPrincipalName Enabled ---- -------------- ----------------- ------- Jane Smith jsmith jsmith@corp.local True
Note: New-ADUser is silent on success — without -PassThru it prints nothing. -PassThru returns the new user object so you can confirm it was created.
Get-ADUser -Filter 'SamAccountName -eq "jsmith"'
Show reference output
Sample output · fictional data, shaped like the real thing
Name SamAccountName Enabled ---------- -------------- ------- Jane Smith jsmith True
Parameters
Parameter definitions:
-Name-SamAccountName-UserPrincipalName-AccountPassword-Enabled-Path-GivenName-Surname-WhatIf
Practical use and troubleshooting
Practical scenario: Use New-ADUser when you need to create an Active Directory user account with identity attributes like -Name, -SamAccountName, -UserPrincipalName, and -AccountPassword. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A duplicate account-name error needs checking existing directory objects. Resolve the intended user and use an update workflow when the account already exists rather than generating an arbitrary new identity. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Set-ADUser. New-ADUser creates a user object; Set-ADUser changes an existing one. Creation settings and subsequent account updates should be reviewed separately in a bulk provisioning workflow. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
New-ADUser Use New-ADUser to create an Active Directory user account with identity attributes like -Name, -SamAccountName, -UserPrincipalName, and -AccountPassword.
Next: Remove-ADUser