Skip to Main Content
Exchange Server Cookbook
book

Exchange Server Cookbook

by Paul Robichaux, Missy Koslosky, Devin L. Ganger
June 2005
Intermediate to advanced content levelIntermediate to advanced
464 pages
13h 2m
English
O'Reilly Media, Inc.
Content preview from Exchange Server Cookbook

5.16. Changing the Display Name Format in the GAL

Problem

Your GAL currently displays user names with the first name first; you need to switch things so that the last name is displayed first.

Solution

Using VBScript

' Script taken from: ' MS KB 277717 (How to Change the Display Names of Active Directory ' Users with Active Directory Services Interface Script) ' This code can change existing users in a given ' organizational unit (OU) to the Lastname, Firstname format rem chgdisplay.vbs - Changes the display names of all users in a given OU to the rem format of Lastname, Firstname. rem Usage = cscript chgdisplay.vbs "OU=My Ou, DC=My Domain, DC=com" rem OU must be enclosed in quotes if it contains spaces in the name Dim strTargetOU ParseCommandLine() wscript.echo strTargetOU wscript.echo wscript.echo "Changing Display names of users in " & strTargetOU Set oTargetOU = GetObject("LDAP://" & strTargetOU) oTargetOU.Filter = Array("user") For each usr in oTargetOU if instr(usr.SamAccountName, "$") = 0 then vLast = usr.get("Sn") vFirst = usr.get("GivenName") vFullname = vLast + ", " + vFirst usr.put "displayName", vFullName usr.setinfo wscript.echo usr.displayName end if Next Sub ParseCommandLine() Dim vArgs set vArgs = WScript.Arguments if vArgs.Count <> 1 then DisplayUsage() Else strTargetOU = vArgs(0) End if End Sub Sub DisplayUsage() WScript.Echo WScript.Echo "Usage: cscript.exe " & WScript.ScriptName & _ " <Target OU to change users display names in>" WScript.Echo "Example: cscript ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® Exchange Server 2010: Best Practices

Microsoft® Exchange Server 2010: Best Practices

Siegfried Jagott, Joel Stidley
Microsoft® Exchange Server 2003 Unleashed

Microsoft® Exchange Server 2003 Unleashed

Rand H. Morimoto - MCSE, Joe R. Coca, CISSP Kenton Gardinier - MCSE MCSA, MCSA Michael Noel - MCSE+I
Microsoft® Exchange Server 2013 Unleashed

Microsoft® Exchange Server 2013 Unleashed

Rand Morimoto, Michael Noel, Guy Yardeni, Chris Amaris, Andrew Abbate

Publisher Resources

ISBN: 0596007175Errata Page