June 2005
Intermediate to advanced
464 pages
13h 2m
English
Your GAL currently displays user names with the first name first; you need to switch things so that the last name is displayed first.
' 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 ...