Creating User Accounts with PowerShell
Still creating accounts by hand? Yeah – we just got out of that boat! If you would like to automate your account creation – here is a sample script you can use!
==============================================
Add-PSSnapin
Quest.ActiveRoles.ADManagement
$Domain=’@YOUR
FULL DOMAIN NAME’
$Userslist=import-csv
“LOCATION to CSV”
#CSV should have
these fields: FN (First Name), LN (Last Name), Pin (logon name).
ForEach
($User in $Userslist)
{
$User.FN
$User.LN
$User.Pin
$FullName=$User.FN+” “+$User.LN
$UPN=$User.Pin+$Domain
$UNC=’HOME DIRECTORY SHARE’
$HomeDirectory=$UNC+$User.Pin
New-QADUser
-name $FullName -FirstName $User.FN -LastName $User.LN -SamAccountName
$User.Pin -DisplayName $FullName -UserPrincipalName $UPN -Office $User.DOB
-UserPassword $User.DOB -ParentContainer
‘OU=Students,DC=GCBE,DC=local’ -HomeDirectory $HomeDirectory -HomeDrive ‘U:’
Set-QADUser
-Identity $User.Pin -PasswordNeverExpires $True
Enable-QADUser
-Identity $User.Pin
Add-QADGroupMember
-Identity SECURITY GROUP TO ADD TO -Member $User.Pin
}
==========================================================
If you run into any trouble (or have thoughts on modifying this script), drop a message!