Set a Users Active Directory Display Name with PowerShell

I recently saw an article on how to set a users Active Directory display name based on the values of their given name, initials, and surname. I came up with my own unique solution for this task and thought I would share it with you, the readers of my blog.

As you can see in the following example, there are a mixture of users who need their display name corrected based on the requirement that their display name be listed as “Givenname Initials Surname”:


I use a simple one-liner to correct the display name of all of the users in the Northwind Active Directory OU (Organizational Unit). One issue though, is that not all users have a middle initial and those users will end up with two spaces in their display name between their first and last name. Instead of using logic to correct that issue, I decided to use a regular expression that matches one or more spaces that are followed by a space:


The previous command is indeed a PowerShell one-liner even though it is on more than one physical line and formatted for readability. A PowerShell one-liner is a command that is one continuous pipeline regardless of how many physical lines it is on. A PowerShell one-liner is NOT defined by the lack of carriage returns <period>.


As you can see in the previous set of results, this task is complete and although only nine users were updated in this example, it could have just as easily been 900 users.

If you live within driving distance of the Birmingham Alabama area, Id like to invite you to attend SQL Saturday #328 on Saturday, August 23rd. I’ll be presenting two awesome PowerShell sessions during the all day track that’s dedicated to PowerShell (room 327).



  1. nnqstthr

    Thank you for this Mike. very excellent

  2. Shahid khan

    Thank you Mike, it was very helpful.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: