17.8k views
0 votes
the gui makes it easy to create one user at a time in active directory. however, sometimes more than one user needs to be created in active directory. what command did you learn about in the lab that can be run at the command line and can add more than one user at a time to active directory? give an example of how you would add yourself as a user to active directory from the command line. reddit

1 Answer

5 votes

In Active Directory, you can use the New-ADUser cmdlet in PowerShell to create multiple users at once. Here's an example of how you can add multiple users, including yourself, to Active Directory from the command line.

# Import the Active Directory module (make sure to run this with administrative privileges)

Import-Module ActiveDirectory

# Define user information

$user1

SamAccountName = "User1"

UserPrincipalName = "user1yourdomain.com"

Name = "User One"

GivenName = "User"

Surname = "One"

DisplayName = "User One"

EmailAddress = "user1yourdomain.com"

Description = "First user description"

AccountPassword = (ConvertTo-SecureString "Password1234" -AsPlainText -Force)

}

SamAccountName = "User2"

UserPrincipalName = "user2yourdomain.com"

Name = "User Two"

GivenName = "User"

Surname = "Two"

DisplayName = "User Two"

EmailAddress = "user2yourdomain.com"

Description = "Second user description"

AccountPassword = (ConvertTo-SecureString "Password5678" -AsPlainText -Force)

}

User MarmiK
by
6.9k points