How to Create Bulk User Accounts in Active Directory using Powershell
Bulk User Account Creation using PowerShell
Provisioning users in Active Directory usually means onboarding the users across Exchange, Microsoft 365 and other systems. However, onboarding multiple users at once can quickly turn out to be a laborious task, with administrators having to repeat the same steps again and again. This also means that administrators can make errors while provisioning users that might prove detrimental to the security of the Windows environment. However, user accounts can be provisioned in bulk more easily with the help of PowerShell script.
Creating bulk users in Active Directory using PowerShell
- Import-Module ActiveDirectory
- $file = "\\SERVER\csv\users.csv"
- $importedUsers = Import-csv $file
- foreach ($user in $importedUsers)
- {
- $sAMAccountName = $user.sAMAccountName
- $password = ConvertTo-SecureString -AsPlainText $user.password -Force
- $givenName = $user.givenName
- $sn = $user.sn
- $ou = $user.ou
- $name = $givenName+"."+$sn
- New-ADUser -SamAccountName $sAMAccountName -Name $givenName
- -AccountPassword $password -GivenName $givenName -Surname $sn
- -Enabled $True -path $ou
- }
By default, when the accounts are created, the users are required to change the default passwords at the next logon. To simplify bulk user creation even further, the script can be scheduled to run periodically.
Related Articles
How to list all user accounts in the domain using Powershell
Active Directory (AD) is the backbone of user authentication and authorization in Windows environments. Managing user accounts within AD is a critical task for system administrators. PowerShell, with its robust capabilities, offers an efficient way ...
List all accounts with disabled Kerberos Preauth using Powershell
Kerberos is the authentication protocol used in Windows domains to provide secure authentication for users and services. One crucial aspect of Kerberos security is preauthentication, which adds an additional layer of security to the authentication ...
Change the password of a domain user account using PowerShell
Managing domain user accounts is a crucial task for system administrators, and one of the common tasks is changing a user's password. PowerShell provides a powerful and efficient way to automate this process. In this comprehensive guide, we will ...
Enumerate Organizational Unit in Active Directory using PowerShell
Active Directory (AD) is the heart of an organization's network infrastructure, providing a structured way to organize and manage resources, users, and computers. One of the fundamental components of AD is Organizational Units (OUs), which act as ...
How to enumerate Active Directory domains using PowerShell
Active Directory (AD) is the backbone of many organizations, serving as a centralized system for managing users, computers, and resources. As a system administrator, being able to enumerate and query AD is a fundamental skill. In this comprehensive ...