Rename all users En Mass

Our school district has chosen to change all users login accounts to their student number, and I am beginning my search on how to accomplish this most effectively and efficiently.  I am sure Powershell will be the way to go and we will essentially be replacing the Account --> User logon name with information already populated in the Lob Title field.  We will also need to replace the current Display Name (as it appears in ADUC) with the information in the Job Title field.

We have almost 5,000 students to rename.  Any assistance would be greatly appreciated.
randaldstowellNetwork EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MASEE Solution Guide - Technical Dept HeadCommented:
You need the take data from job tiltle and make it as login name.
Please let me know if I am wrong.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Please show the exact changes needed by providing an example.
randaldstowellNetwork EngineerAuthor Commented:
Here's the current login name format:
User Account Logon Name Field
Here's what we are changing it to (Unique for each of our 5000 Students)
User Job Title Field
In this example, user 22-camps login name would be changed to 220062.  Essentially, we have to replace what is currently in the Account User logon name field with the values that are currently in the Organization Job Title field.  We have to perform this modification to 5000 Student accounts in Active Directory.

Hope this is a better explanation of what we are trying to accomplish.
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

MASEE Solution Guide - Technical Dept HeadCommented:
If you update the accounts by one command it may create problems from you as it will update the system accounts.
I suggest you export the users using the below command and delete the system accounts/Users from the CSV file.
 
Import-module activedirectory
Get-ADUser -Filter * -Properties * | Select-Object -Property Name,SamAccountName,UserPrincipalName,Title | Sort-Object -Property Name | Export-csv C:\users.csv

Open in new window

 

And update using the below command
Try with few accounts first then do the rest.
Import-Csv D:\users.csv | foreach {Set-ADUser -identity $_.Name -UserPrincipalName $_.UserPrincipalName -SamAccountName $_.SamAccountName}

Open in new window

Your CSV file should look like the attached file
EE1.png
David Johnson, CD, MVPOwnerCommented:
so you want to change the display name and the samaccountname (login name) to the job title do you want to keep the current login name in the job title area?
compdigit44Commented:
MAS brings up a good point change all accounts at once would hit the system account which would be not good.  Also have you thought out how changing the users login name will impact email / Exchange? Will users keep their current email format or does the alias need to be updated ? Also what about third party applications that users access, if they are not AD integrated their account DB's would need to be updated as well.
randaldstowellNetwork EngineerAuthor Commented:
Thank you for the replies and the direction.

Here's what works:

1)  Started with the following script:

import-module activedirectory
$Path = 'OU=Students,OU=AnySchool,DC=MyDistrict,DC=edu'
$users = Get-ADUser -filter * -SearchBase $Path | select-object samaccountname, name, UserPrincipalName,Title | Sort-Object -Property Name | Export-csv C:\Students-in-Target-OU.csv

2)  Using the data from the CSV created in step #1, I renamed the NAME property on all accounts with the following Powershell command:

Rename-ADObject -Identity      'CN=AccountName,OU=Students,OU=AnySchool,DC=MyDistrict,DC=edu'      -NewName      456789

This successfully renamed the accounts with the Student ID #.

3)  With ADUC now displaying the Students ID # as Name, I modified the CSV in step 1 as follows:

samaccountname      name                                                                                                      UserPrincipalName
456789                      CN=456789,OU=Students,OU=AnySchool,DC=MyDistrict,DC=edu      456789@mydistrict.edu

4)  Finally, I ran the following command:

Import-Csv C:\Students-in-Target-OU.csv | foreach {Set-ADUser -identity $_.Name -UserPrincipalName $_.UserPrincipalName -SamAccountName $_.SamAccountName}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Seth SimmonsSr. Systems AdministratorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.