Link to home
Start Free TrialLog in
Avatar of hutnor
hutnorFlag for United States of America

asked on

How do I add many users in windows Server 2008 without clicking add user for every single one.

Hi

I would like to know how I add LOTS of users in windows 2008 server without clicking add new user for every single person i need to add.
ASKER CERTIFIED SOLUTION
Avatar of John_Chambers
John_Chambers
Flag of Korea, Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of XT
Avatar of hutnor

ASKER

The ldifde looks to confusing / hard to do then powershell.

Does that power shell script also make mailbox for the user in exchange? Along with a profile & home path? How can I add this in if it is not there.

I would like to understand each line before I use it. Can please tell me what they do I am a bit confused what is happening in the middle of the script & if I can change anything in there to suit what I want better?


If I want to change the OU from
"$objOU=[ADSI]“LDAP://OU=People,DC=sysadmingeek,DC=com”"

Do i use something like this?
$objOU=[ADSI]“LDAP://OU=newusers,OU=company,DC=mydomain,DC=local”

So this will put them in a OU call newusers that is located under a OU call company in mydomain.local?


##sets OU user are put into & domain 
$objOU=[ADSI]“LDAP://OU=People,DC=sysadmingeek,DC=com”
##selects file of user names
$dataSource=import-csv “users.csv”
foreach($dataRecord in $datasource) {
$cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName
$sAMAccountName=$dataRecord.FirstName + “.” + $dataRecord.LastName
$givenName=$dataRecord.FirstName
$sn=$dataRecord.LastName
$sAMAccountName=$sAMAccountName.ToLower()
$displayName=$sn + “, ” + $givenName
$userPrincipalName=$sAMAccountName + “@sysadmingeek.com”
$objUser=$objOU.Create(“user”,”CN=”+$cn)
$objUser.Put(“sAMAccountName”,$sAMAccountName)
$objUser.Put(“userPrincipalName”,$userPrincipalName)
$objUser.Put(“displayName”,$displayName)
$objUser.Put(“givenName”,$givenName)
$objUser.Put(“sn”,$sn)
$objUser.SetInfo()
##sets users password
$objUser.SetPassword(“P@assw0rd”)
##will make the account disable or enabled
$objUser.psbase.InvokeSet(“AccountDisabled”,$false)
$objUser.SetInfo()
}

Open in new window