Exchange Server Share

August 17, 2008

Exchange 2007 & Display Name Format

Here is another good question asked on TechNet forum about “Exchange 2007 & Display Name” – How to change the display name format from <First Name> <Initial> <Last Name> to <Last Name>, <First Name> <Initial> in Exchange 2007 user/mailbox creation process?”

 

Let’s start with some Exchange 2003 background…

Exchange 2003:

We use Active Directory Users & Computers (ADU&C) to create users/mailboxes. By default name & display name formats are “<First Name> <Initial>. <Last Name>” in ADU&C creation process but it can be changed to “<Last Name>, <First Name> <Initial>” by setting createDialog attribute of the user-Display object under CN=DisplaySpecifiers, CN=409 object (409 represent U.S. English language) in the configuration naming context by using ADSIEDIT.msc to value %<sn>, %<givenname> %<initials>.

Procedure is explained here: How to change display names of Active Directory users

image

After setting createDialog value while creating user/mailbox when we enter First name, Last name & Initials fields, it takes Full name in <Last Name>, <First Name> <Initial> format automatically (we don’t have to enter it manually) .

image

Display name sets same as Full Name automatically when you create any users.

image

 

Now, let’s talk about Exchange 2007.

Exchange 2007:

When we create mailbox for new user in Exchange Server 2007 Exchange Management Console, it does not recognize the value of the createDialog attribute of user-Display object of a displaySpecifier class and stays with default format <FN> <I> <LN>.

Dave explained here that it is by design and limitation of EMC. Workaround is to create users with ADU&C MMC and later create mailboxes for those users with EMC.

Changing the display name of active directory users.

 

Now, some questions come here…

1. How do I change Name & Display Name of existing users, if I already created some of the users with EMC?

Here is an example where users are already created in <FN> <I>. <LN> format with Exchange 2007 – EMC.

image

You don’t have to worry about changing all those one by one since PowerShell is your friend. Here is the script which changes the name & display name format of all mailbox users to <LN>, <FN> <I>.

To run PowerShell scripts you need to change Execution Policy in EMS.

Go to Exchange Management Shell and execute below command to set execution policy so you can run the ps1 scripts.

Set-ExecutionPolicy RemoteSigned

image

Now, save below script in C:\Scripts\Pre-Users.ps1 file.

=====================Pre-User.ps1=====================

# Pre-Users.ps1 - Change the name & display name of existing users.
# Created by - Amit Tank
$Users = Get-User -ResultSize unlimited | where {$_.RecipientTypeDetails -eq "UserMailbox"}
ForEach ($User in $Users)
{
$DName = $User.LastName + ", " + $User.FirstName + " " + $user.Initials
$DName = $Dname.Trim()
Set-User $User -Name $DName -DisplayName $DName
Get-User $User | FT Name, DisplayName
$DName = $Null
}

image

Go to Exchange Management Shell and execute the script with ./Pre-Users.ps1 command.

image 

Well, all Name & Display Name are set in <LN>, <FN> <I> format.

Depending on the format of Room/Shared mailboxes in your organization you can change name & display name of those also. You need to change below line in the script based on your requirement.

$Users = Get-User -ResultSize unlimited | where {$_.RecipientTypeDetails
-eq “RoomMailbox”}

$Users = Get-User -ResultSize unlimited | where {$_.RecipientTypeDetails
-eq “SharedMailbox”}

2. What should I do if I want to create users/mailboxes with EMC/EMS with  correct format?

EMC:

Make a practice or document it in user/mailbox creation process manual of your organization that “Name” filed should be given in <LN>, <FN> <I> format manually (EMC sets Display Name same as a Name).

image

image

EMS:

Same as EMC, Make a practice or document it in user/mailbox creation process manual of your organization that “Name” & “Display Name” should be given in <LN>, <FN> <I> format by specifying -Name & -DisplayName switches.

New-Mailbox -Alias HWood -Database “First Storage Group\Mailbox Database” -Name “Wood, Haley V” -OrganizationalUnit “ESS-Test.com/Users” -FirstName Haley -LastName Wood -Initial V -DisplayName “Wood, Haley V” -UserPrincipalName HWood@ESS-Test.com

image

3. How do I make sure that new users/mailboxes will be created with correct format?

Well, you can schedule a PowerShell script which runs every night and verifies the mailboxes which are created in last 24 hours and correct the format if it is not in correct one.

Create below two files in C:\Scripts folder on your Exchange server.

=============UserName.CMD=============

Powershell -command "& {C:\Scripts\UserName.ps1 }"

 

image

=====================UserName.PS1=====================

# UserName.ps1 - Change the name & display name of users which are created in last 24 hours.
# Created by - Amit Tank
 
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
 
$Users = Get-User -ResultSize Unlimited | where {($_.WhenCreated -gt (get-date).adddays(-1)) -and ($_.RecipientTypeDetails -eq "UserMailbox")}
ForEach ($User in $Users)
{
$DName = $User.LastName + ", " + $User.FirstName + " " + $user.Initials
$DName = $Dname.Trim()
Set-User $User -Name $DName -DisplayName $DName
Get-User $User | FT Name, DisplayName
$DName = $Null
}

image

Now create a Task in windows task scheduler to run this script at 12:00AM midnight.

image

All set, now this automation will take care about newly created mailboxes every night.

eg. I have below user created with wrong name & display name format which has taken care by this midnight scheduled script.

image

image

You may also add a code in PowerShell script to trigger a mail to administrator for the confirmation that script has run and changed the display names successfully.

About these ads

7 Comments

  1. I found your site on technorati and read a few of your other posts. Keep up the good work. I just added your RSS feed to my Google News Reader. Looking forward to reading more from you down the road!

    Comment by Sue Massey — August 17, 2008 @ 4:02 pm

  2. [...] Exchange 2007 & Display Name Format [...]

    Pingback by Weekend reading - subject: exchange — August 22, 2008 @ 6:58 pm

  3. Dave gave update on his blog….

    Update – Changing the display name of active directory users

    http://blogs.msdn.com/dgoldman/archive/2008/08/18/update-changing-the-display-name-of-active-directory-users.aspx

    Comment by Shaik Raheem — September 7, 2008 @ 2:02 pm

  4. undeniably…..

    Comment by StreetM — September 8, 2008 @ 8:04 pm

  5. Nice article, thanx! May I translate it into Russian and publish with reference to your, original article?

    Comment by luckyredhot — August 3, 2009 @ 5:29 pm

    • Yeh sure, thanks for getting approval… :)

      Comment by Amit Tank — August 3, 2009 @ 7:46 pm

      • thanx, I also changed a bit this script above so even I may be called co-author :-p

        Comment by luckyredhot — August 3, 2009 @ 8:08 pm


RSS feed for comments on this post.

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: