Score:0

Change AD Display name from Lastname, Firstname to Firstname Lastname

it flag

My organization wants to change the Display name format to Firstname Lastname instead of Lastname, Firstname

I already change the format for creating new users in the ADSI settings. But want to change all current users display name to Firstname Lastname

I found a script in: Default full name format in Active Directory

Get-ADUser -LDAPFilter "(&(objectCategory=person)(!displayName=*,*)(displayName=*))" |
ForEach-Object {  
    Set-ADUser $_ -DisplayName "$($_.Surname), $($_.givenName)"
}

This change it from Firstname Lastname to Lastname, Firstname. I want to do a reverse, so I tweak this script to:

Get-ADUser -LDAPFilter "(&(objectCategory=person)(!displayName=*,*)(displayName=*))" |
ForEach-Object {  
    Set-ADUser $_ -DisplayName "$($_.givenName) $($_.Surname)"
}

But my AD users have still a display name like Lastname, Firstname. PS do not give any warnings or errors and did a refresh in AD.

Do someone knows a trick to change all AD users to Firstname Lastname as Displayname?

Score:3
in flag

The problem is the filter. The string (!displayName=*,*) indicates that only user who currently don't have a , in their displayname should be changed. You want the inverse, so you need to remove the !.

Get-ADUser -LDAPFilter "(&(objectCategory=person)(displayName=*,*))" |
ForEach-Object {  
    Set-ADUser $_ -DisplayName "$($_.givenName) $($_.Surname)"
}
ricardovand3rlinden avatar
it flag
It works! Thank you =] I also notice that the wildcard gets deleted '(displayName=*)' from the filter. Why is that?
in flag
Because it's redundant. `displayname=*` filters for all objects where the displayname is not empty. If it contains a `,` it is not empty, so it's no use to check that again.
ricardovand3rlinden avatar
it flag
Thanks again, very helpful explanation.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.