Description
import users from CSV to AD
Source Code
CSV should be set out like:
FirstName LastName UserName Fullname PrincipleName
Alex Chung Alexc Alex Chung Alex.chung@COMPANY.co.uk
Powershell command to import the users:
$Users = Import-Csv -Path C:\Users\Documents\usernames.csv
$OU = 'ou=USERS,dc=DOMAIN,dc=co,dc=uk'
foreach ($User in $Users)
{
New-ADUser -Name $User.Fullname -Path $OU -GivenName $User.FirstName -Surname $User.LastName -SamAccountName $User.UserName -DisplayName $User.Fullname -UserPrincipalName $User.PrincipleName -AccountPassword (ConvertTo-SecureString "Password1" -AsPlainText -Force)
}
2 Spice ups
jimlong3
(Jim6795)
2
How do you load usernames.csv? Is it possible to pull every Active User from one AD with all their Properties & then “New-ADUser” them all directly into the new AD, preserving all Properties & Attributes?