Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Active Directory

Posted on 2016-10-26
2
Medium Priority
?
79 Views
Last Modified: 2016-11-01
Hi, I need a script to create users in Active Directory. I have some 1000 users which I need to be created in our active directory. Can any expert help me out with the script. AD is having OS Windows 2012 R2 standard edition.
0
Comment
Question by:SYZH
2 Comments
 
LVL 1

Assisted Solution

by:Erik D'antoni
Erik D'antoni earned 1000 total points
ID: 41860674
0
 
LVL 17

Accepted Solution

by:
Todd Nelson earned 1000 total points
ID: 41860792
Basically, create a CSV file and use with script.  Here are a couple of references.  The last two, in part, will guide you to creating a CSV file and the users...


Essentially, the CSV file (saved as 'MyNewUsers.csv') and script will look similar to this...

Name,UserPrincipalName,DisplayName,FirstName,LastName,OUPath,EmailAddress
User0,User0@mydomain.local,User 0,User,0,"OU=Test,OU=Users,DC=mydomain,DC=local",user0@mydomain.com
User1,User1@mydomain.local,User 1,User,1,"OU=Test,OU=Users,DC=mydomain,DC=local",user1@mydomain.com
User2,User2@mydomain.local,User 2,User,2,"OU=Test,OU=Users,DC=mydomain,DC=local",user2@mydomain.com
User3,User3@mydomain.local,User 3,User,3,"OU=Test,OU=Users,DC=mydomain,DC=local",user3@mydomain.com

Open in new window


Import-Module ActiveDirectory
$MYPASSWORD = Read-Host "Enter Password" -AsSecureString
Import-Csv "C:\MyNewUsers.csv" | ForEach-Object {
     New-ADUser -Name $_.Name -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName -GivenName $_.FirstName -Surname $_.LastName -Path $_.OUPath -Email $_.EmailAddress -AccountPassword $MYPASSWORD -PasswordNeverExpires $False -Enabled $True
}

Open in new window

1

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Let's recap what we learned from yesterday's Skyport Systems webinar.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question