This PowerShell scripts shows how to create user accounts that are located in a .csv file and move it to a specified OU.
You can add lots of attributes to the New-ADUser cmdlet for example: –mail –manager –mobile etc.
I created a users.csv file before I executed this script:
FirstName | LastName | SamAccountName | Password |
Maarten | Peeters | m.peeters | P@ssw0rd! |
# Created by Maarten Peeters # https://www.sharepointfire.com # Created this script using Windows Server 2012# Import Active Directory module Import-Module ActiveDirectory -ErrorAction SilentlyContinue# Set OU for the user accounts $OU = “OU=Users,OU=Domain environment,DC=peet,DC=local” # Get domain name # Import the file with the users. foreach ($user in $users) # Get password from CSV File # Create Accounts $FullName = ($user.FirstName + ” ” + $user.LastName) try } |