Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing several lines of text

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hi All
Not sure how to go about doing this. I have an ldifde file I want to import into AD. There are 200 users. I want to change the samaccountname to be first initial last name. How would I go through the entire file and make the changes?
Thanks.

dn: CN=Aaliyah Moosbrugger,OU=SantaMonica,DC=vmnet,DC=com
changetype: add
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
cn: Aaliyah Moosbrugger
givenName: Aaliyah
sAMAccountName: MoosbAa
 
You don't specify what your naming convention is. Is it ALWAYS the first two letters of the first name on the end? If so then it is easy.

Code:
line ="sAMAccountName: MoosbAa"

If InStr(1,line,"sAMAccountName:") > 0 Then
	samName = Right(line,Len(Line)-16)
End If
WScript.Echo samName
FirstTwo = Right(samName,2)
LastPart = Left(samName,Len(samName)-2)

samNameRedo = FirstTwo & LastPart
WScript.Echo samNameRedo

If you don't have such a rule then I don't think you will be very successful with this because there are likely to be too many exceptions.

For example, my first thought was you could check for uppercase letters, but a last name like mine would likely ruin that logic. (MacLachlan)


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top