Jump to content

Recommended Posts

Posted

Morning all,

 

Does anyone have a quick easy way to change a year groups display name to be the same as their username in AD.

I was hoping you could do it as a bulk action in AD by selecting all going to properties and setting display name to %username% but sadly you can't seem to edit the display name in this way.

 

Many thanks

Posted (edited)

You could do this with PowerShell:

 

$users = Get-ADUser -SearchBase "insert OU Path"  -Filter * -Properties *

foreach($user in $users){
   $username = $user.SamAccountName
   Set-ADUser -Identity $Username -DisplayName $Username
}

 

You'll need to find the DN name of the OU if you are targeting an OU, easiest way to get it to make sure you have Advanced Features on under "View" in Active Directory, right click the OU with your year group in, go to Attribute Editor tab and copy the DistinguishedName in there and paste it "insert OU Path" part of this script.

Edited by ShellfishClive
  • Thanks 2
Posted
I always add this when i see -filter * and - properties * on any command. Can we be careful when running commands with this as you would not be popular running that against large directories! Look back through my pasts posts for more.
Posted
I did a project about 7 years ago at a previous place where we changed the display name, upn, username and alligned the users home folder to the same username. If I can find the script I dig it out.

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...