user names in Active Directory

R

Robert

I have about 8000+ existing accounts that need to have
user name added to the account tab. Most have pre-windows
2000 names, but no user logon name. How can I script it
to add all of the names into the logon name field? I do
not want to go through all 8000+ names one at a time. Any
help will be greatly appreciated.
 
M

Michael Holzemer

Robert said:
I have about 8000+ existing accounts that need to have
user name added to the account tab. Most have pre-windows
2000 names, but no user logon name. How can I script it
to add all of the names into the logon name field? I do
not want to go through all 8000+ names one at a time. Any
help will be greatly appreciated.

User logon name is part of the UPN for the user.
One way to do it would be to loop through all users by using ADO and change
the UPN property. Another is to do it from a list of the common names.

So this file would contain a list of users in the comma delimited format of
First Name, Last Name and would create the logon name of first initial of
the first name and the entire last name.

For a user named John Brown logon name jbrown
The file reads
John, Brown

Const ForReading = 1
Set oFSO = CreateObject("scripting.filesystemobject")
Set oTF = oFSO.OpenTextFile("C:\My8000Users.csv",ForReading,True)
Do While oTF.AtEndOfStream <> True
sLine = oTF.ReadLine
aLine = split(sline, ",",-1,1)
sCN = Trim(aLine(0)) & " " & Trim(aline(1))
sLogon = left(Trim(aLine(0)),1) & Trim(aline(1))
'// Edit this to reflect your domain settings
Set objOU = GetObject("LDAP://cn=" & sCN &
",ou=MyUserOU,dc=galaxy,dc=nasa")
On Error Resume Next
'// Edit this for your UPN extension like "@domain.com"
objuser.put "userPrincipalName", lcase(sLogon) & "@galaxy.nasa"
objUser.SetInfo
Loop

--
Regards,

Michael Holzemer
No email replies please - reply in newsgroup

Learn script faster by searching here
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top