Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Creating New User Accounts in Active Directory with ADUC and PowerShell

March 15, 2024

Creating New User Accounts in Active Directory with ADUC and PowerShell

In this article, we’ll look at how to create new users in an Active Directory domain. You can create new user accounts in your domain using the graphical MMC snap-ins ( Active Directory Users and Computers dsa.msc and AD Administrative Center dsac.msc) or with PowerShell scripts.

Contents:
  • How to Create a New Active Directory User with ADUC?
  • New-ADUser: Creating Active Directory Users with PowerShell
  • Bulk Create Active Directory Users from CSV with PowerShell

How to Create a New Active Directory User with ADUC?

The easiest way to create a new domain user in Active Directory is to use the graphical ADUC mmc console.

  1. Open the Active Directory Users and Computers console by running the dsa.msc command;
  2. Select the Active Directory container (Organizational Unit) in which you want to create a new user account. Right-click on it and select New -> User;     create new user with aduc console
    To create new users in the domain, your account must be a member of the Domain Admins or Account Operators groups. Or you can manually delegate user creation permissions to other domain users and groups.
  3. Specify the user’s first name, last name, full name, and set userPrincipalName (user login name) and sAMAccountName. Click Next;create new ad user object wizard
  4. Then set the user password. set active directory user account password propertiesOn this form, you can additionally set the following options for the UserAccountControl attribute:
    User must change password at next logon;
    User cannot change password – only the administrator/account operator can change/reset the user password;
    Password never expires – user password will never expire (if this option is not enabled, then user password expiration is determined by the Active Directory domain password policy);
    Account is disabled – the user account in the domain is disabled and cannot be used to log in.
  5. Find the user in the ADUC console and open its properties. Here you can set additional user attributes: phone number, address, description, position, company (etc.), add them to AD groups and set other attributes on the Attribute Editor tab.ad user properties

You can create new AD users with similar settings by copying them. This way of creating new users is suitable for creating another user from the same department, with the same set of permissions, address, and description.

copy active directory user

Click on the user and select Copy. When copying an AD user, the group membership, address (except street), useraccountcontrol attribute settings, organization settings, and several other attributes will be copied to the new user account.

New-ADUser: Creating Active Directory Users with PowerShell

Above, we showed you how to manually create a user in an Active Directory domain using the ADUC graphical snap-in. If you’re constantly adding new users to your domain, it’s much more convenient to automate this process using PowerShell.

You can use the New-ADUser cmdlet from the Active Directory for Windows PowerShell module to create user accounts in AD.

You can get the full syntax of New-ADUser cmdlet using the command:

Get-Command New-ADUser –Syntax

New-ADUser powershell cmdlet

In the simplest case, to create a new user account in AD, it is enough to specify only its name:
New-ADUser testuser1

create new ad user object using powershell

As you can see, a new user account has been created in the default Users container. This user is disabled by default. To use this account, you must enable it (Enable-ADAccount cmdlet), set its password (Set-ADAccountPassword cmdlet) configure other attributes (if necessary).

To create a new account in a specific Active Directory container of the domain (OU) with a password and enable it immediately, use the following command:

New-ADUser -Name "Albert Schmidt" -GivenName "Albert" -Surname "Schmidt" -SamAccountName "a.schmidt" -UserPrincipalName "[email protected]" -Path "OU=Users,OU=Accounts,OU=Berlin,OU=DE,DC=woshub,DC=com" -AccountPassword(Read-Host -AsSecureString "Input Password") -Enabled $true

New-ADUser How to Create New Active Directory Users with PowerShell

The command prompts you to securely specify the password for the new user.

Note. The user’s password must comply with the domain password security policy by length, complexity, etc., otherwise, the cmdlet will return the error: New-ADUser: The password does not meet the length, complexity, or history requirement of the domain. You can use a ready-made PowerShell script to generate a complex password for each user.

You can get the information about the created domain user using the Get-ADUser cmdlet:

Get-ADUser a.schmidt

Bulk Create Active Directory Users from CSV with PowerShell

You can use PowerShell scripts to bulk-create multiple users in an Active Directory domain. Consider a simple script to create user accounts from a list in a CSV file.

Fill in the required user attributes in the CSV (Excel) file format. For example, my Excel file with users has 8 columns and has the following header format:

FirstName;LastName;SamAccountName;Phone;Department;JobTitle;Password;OU

Save the Excel file as a CSV format with commas as delimiter. The encoding must be set to UTF-8 (it’s important!).

You can access values in Excel cells directly from PowerShell. I use a flat CSV file to simplify the script code in this example.

Create New Active Directory Users with Excel and PowerShell

Now you can import this CSV file (create_ad_users.csv) and create new users in the AD domain. See the following example of a PowerShell script that can be used to create users in Active Directory.

Bulk crea AD users using a CSV file and New-ADUser

Note.

  • Specify the name of the OU in which you want to create a new user account in the distinguishedName format ("OU=Users,OU=Munich,OU=DE,DC=woshub,DC=com" ). The value must be enclosed in double quotes (because the string contains commas);
  • If “;” is used as the delimiter character for the CSV file, add the -delimiter ";" as an argument of your Import-Csv command;
  • The script checks if the user exists in the domain. If such an account already exists in the domain, a warning appears and prompts you to enter a unique sAMAccountName.


Import-Module activedirectory
$domain=“@woshub.com”
Import-Csv "C:\ps\create_ad_users.csv" | ForEach-Object {
$userSAM=$_.SamAccountName
if (@(Get-ADUser -Filter "SamAccountName -eq '$($_.SamAccountName)'").Count -ne 0) {
Add-Type -AssemblyName Microsoft.VisualBasic
$userSAM = [Microsoft.VisualBasic.Interaction]::InputBox("User $_.SamAccountName exists", 'Specify a new user SamAccountName', $_.SamAccountName)
}
$upn = $userSAM + $domain
$uname = $_.LastName + " " + $_.FirstName
New-ADUser -Name $uname `
-DisplayName $uname `
-GivenName $_.FirstName `
-Surname $_.LastName `
-OfficePhone $_.Phone `
-Department $_.Department `
-Title $_.JobTitle `
-UserPrincipalName $upn `
-SamAccountName $userSAM `
-Path $_.OU `
-AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -Enabled $true
}

bulk create new active-directory user from csv file with powershell script

In addition, you can save user creation info to a log file (an example of using log files in PowerShell scripts).

After running the script, open the ADUC console, expand the specified Active Directory OU, and make sure that new user accounts have appeared in the AD. You can track new user account creation events as follows: Get a list of Active Director use accounts created in the last X hours/days.

new user in active directory

You can immediately add new user accounts to the specific AD groups using the Add-AdGroupMember cmdlet. To do this, you need to slightly modify the script by adding this line to the For-Each loop:

Add-AdGroupMember -Identity AllowInternetAccess-Members $userSAM

Or you can set the user’s photo in AD to display it in Outlook and Lync using the Set-ADUser cmdlet:

Set-ADUser $userSAM -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\ps\l.wolf.jpg" -Encoding byte))}

6 comments
3
Facebook Twitter Google + Pinterest
Active DirectoryPowerShellWindows Server 2019
previous post
The update is not applicable to your computer: Windows Update Error
next post
Tutorial: Install and Configure WSUS on Windows Server 2022/2019

Related Reading

Wi-Fi (Internet) Disconnects After Sleep or Hibernation on...

March 15, 2024

PowerShell: Get Folder Size on Windows

April 2, 2024

How to Download Offline Installer (APPX/MSIX) for Microsoft...

March 12, 2024

How to Find the Source of Account Lockouts...

March 12, 2024

How to Delete Old User Profiles in Windows

March 15, 2024

Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)

March 17, 2024

Start Menu or Taskbar Search Not Working in...

April 22, 2025

How to Backup and Restore Websites and IIS...

June 8, 2023

6 comments

johan May 19, 2019 - 12:19 pm

script doesnt work

New-ADUser : Cannot validate argument on parameter ‘Path’. The argument is null or empty. Provide an argument that is not null or empty, and
then try the command again.
At line:14 char:7
+ -Path $_.OU `
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Reply
admin July 8, 2019 - 5:29 am

Show me your whole New-ADUser command

Reply
john December 31, 2021 - 7:46 am

Import-Csv “C:\Users\cammy\Desktop\BULKCREATE.xlsx” | ForEach-Object $upn = $_.SamAccountName + “@mydomain.com” $uname = $_.LastName + ” ” + $_.FirstName New-ADUser -Name $uname ` -DisplayName $uname ` -GivenName $_.FirstName ` -Surname $_.LastName ` -UserPrincipalName $upn ` -SamAccountName $_.samAccountName ` -Path $_.OU ` -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -Enabled $true

Reply
Battumur Munkhbaatar May 7, 2020 - 3:51 pm

New-ADUser : Cannot bind parameter ‘AccountPassword’. Cannot convert the
“User@cbps123!” value of type “System.String” to type
“System.Security.SecureString”.
At line:19 char:18
+ -AccountPassword $_.Password `
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-ADUser], ParameterBindi
ngException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.ActiveDi
rectory.Management.Commands.NewADUser

Reply
admin May 8, 2020 - 8:20 am

don’t use @ character as a part of user password in your powershell scripts. This is a special character. Or change it to `@

Reply
James September 7, 2020 - 9:26 pm

Do you need Excel running if you run this on the DC?

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Configure Google Chrome Settings with Group Policy
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • Allow Non-admin Users RDP Access to Windows Server
  • How to Find the Source of Account Lockouts in Active Directory
  • How to Disable or Enable USB Drives in Windows using Group Policy
  • Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
  • Configuring Proxy Settings on Windows Using Group Policy Preferences
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top