Jump to content

Recommended Posts

Posted (edited)

You can use DSMOD to change attributes. I had to to it a while back to fill in information for our exchange server. You create a spread sheet with all your users and then add the entries as follows. You can export your users using dsmod or csvde I can't remember which one. and insert them into the sheet

 

dsmod user "CN=testpupil,OU=Intake02,OU=student,OU=Accounts,DC=jschs,DC=local" -fn Joe -ln Bloggs -desc PUPIL -office SM -dept SM -company "Your school"

 

You then export it from excel to a text file and then change it to a bat file and run it on your domain controller. You can change any attribute you like.

Edited by jsnetman
  • 8 months later...
  • 2 years later...
Posted

Bit of an old thread, but i'm doing this just now. I'm in the process of updating my AD fields, i use the addusers command line tool which only fills in the display name, not first/last name.

 

I created a csv with student logon, name and surname in separate columns, then mailmerged it with the following:

 

dn: CN=,OU=Year XX Students,OU=School Students,OU=School Users,OU=School Name,OU=Schools,DC=Education

changetype: modify

replace: givenName

givenName:

-

replace: sn

sn:

-

replace: mail

mail: @domain.edu

-

replace: userPrincipalName

userPrincipalName: @domain

-

changeType: modrdn

newRdn: CN= ,OU=Year XX Students,OU=School Students,OU=School Users,OU=School Name,OU=Schools,DC=Education

deleteOldRdn: 1

 

You need to make sure there's one blank line between each record, then use ldifde to import the file. Command line is

ldifde -i -f filename.txt -s server

You can also add -j for logging, -v for verbose and -k for ignoring the 'object does not exist' error.

 

Bit longwinded but it seems to work.

  • Thanks 1
Posted (edited)

CSV into powershell is probably the best way these days?

 

 

To Create:

 

Import-Csv c:\users.csv | ForEach
{
 $Name = $_.givenName + " " + $_.sn
 New-ADUser 
   -Name $Name `
   -sAMAccountName $_.sAMAccountName `
   -GivenName $_.givenName `
   -Surname $_.sn `
   -Initials $_.initials `
   -DisplayName $_.displayName `
   -Department $_.department `
   -AccountPassword $_.ctPassword `
   -Path $_.OU `
   -ChangePasswordAtLogon $true ` 
   -Enabled $true
}

 

To Update:

 

Import-Csv c:\users.csv | ForEach ($User in $Userscsv)
{
 Set-ADUser $User.sAMAccountName 
   -Replace @{
         title =$user.'job title'; 
         company = $User.'business unit'; 
         department = $User.'home department'; 
         telephonenumber = $User.'work phone'; 
         mobile = $User.'work wireless' 
         }
}

Edited by Geoff
  • Thanks 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...