Notes from the field – Part II: scripting

During the migration project I was involved in, I did a lot of scripting. There are a lot of tasks that can only be done by extensive manual labor or by a script. I prefer this last option!

One of the tasks I had to do was to create a lot of mail-enabled contacts in the Active Directory. The script that does this reads the information needed from a text file and the creates the AD objects. The text file has the following format:


And here’s the VBScipt that does all the work:

Option Explicit
Const ForReading = 1
Const ForWriting = 2

Dim objFSO, objFileIn, objOU, objUser
Dim MyArray, strName, strMail

On Error Resume Next
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFileIn = objFSO.OpenTextFile(“INPUT_FILE.txt”, ForReading, True)

Set objOU = GetObject(“LDAP://ou=Contacts,dc=domain,dc=com“)

Do While Not objFileIn.AtEndofStream
MyArray = Split(objFileIn.ReadLine, “;”, -1, 1)
strName = MyArray(0))
strMail = MyArray(1)

Set objUser = objOU.Create(“contact”, strName)
objUser.Put “Description”, strName
objUser.Put “Mail”, strMail



Technorati : ,

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top