?
Solved

Modifying AD username

Posted on 2015-01-07
6
Medium Priority
?
59 Views
Last Modified: 2015-01-12
I am moving over 200 users to a different site and changing OU's so I also need to change their SAMAccount name as well. For example John Doe in Baltimore, MD would be BALJDoe and he will move to Portland, OR and gets renamed to PORJDoe. I don't want to change the AD account one by one. What's the best way to do this for over 200 users?
0
Comment
Question by:CiscoAzn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40536054
Most effective way is with powershell.

Create a CSV file with the following headings...
CurrentSAM   NewSAM
johndoe           BALjdoe
etc...

Once you have your CSV file created use the following script to change all of the users sAMAccountNames
import-module activedirectory
$UserMod = import-csv "c:\yourcsvhere.csv"
foreach ($entry in $UserMod) {
$entry.CurrentSAM
$entry.NewSAM
Get-Aduser -Identity $entry.CurrentSAM | Set-Aduser -sAMAccountName $entry.NewSAM
}

Open in new window


The above code will go through each on in the list and update the sAMAccountName to the New one you have listed in the csv file.

Will.
0
 

Author Comment

by:CiscoAzn
ID: 40536068
Can you specify in the code to point to a particular OU where all these users are in?
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40536136
When you use the get-aduser cmdlet you do not need to specify the OU that the users resides.

You can also just add 1 user to the csv file, then run the script and ensure that no errors come back.

Will.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:CiscoAzn
ID: 40545233
This changes the pre-Windows 2000 name but not the actual logon name.
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 2000 total points
ID: 40545242
If you also want the UPN (name@domain,com) you will need to add another column to the CSV file and use the below code...

CSV file format
CurrentSAM   NewSAM      NewUPN
johndoe           BALjdoe      BALjdoe@domain.com
etc...

import-module activedirectory
$UserMod = import-csv "c:\yourcsvhere.csv"
foreach ($entry in $UserMod) {
$entry.CurrentSAM
$entry.NewSAM
$entry.NewUPN
Get-Aduser -Identity $entry.CurrentSAM | Set-Aduser -sAMAccountName $entry.NewSAM -UserPrincipalName $entry.NewUPN
}

Open in new window


Will.
0
 

Author Closing Comment

by:CiscoAzn
ID: 40545324
Worked perfectly. Thanks for the help.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question