Here is the start of a script to pull user information into a tab seperated file from Exchange users.
'==========================================================================
' NAME: listSMTPinfoDump.vbs
' AUTHOR: Steven Peck
' DATE: 11/11/2005
'
' COMMENT: outputs tab seperated file information
' FirstName, LastName, DisplayName, EmployeeID, emailAddress
' Information output to file: c:\output.txt
'MODIFIED:
'
'==========================================================================
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Today = Month(Now) & "." & Day(Now) & "." & Year(Now)
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
' setup for writing file
Set objWMIService = GetObject("winmgmts:")
Set colServices = objWMIService.ExecQuery("SELECT * FROM Win32_Service")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.CreateTextFile("C:\" & Today & "ADlist.txt")
' Write file header
objTS.WriteLine "First Name" & vbTab & "Last Name" & vbTab & "Display Name" _
& vbTab & "Employee ID" & vbTab & "Email Address"
' Start of ADSI
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
' Set ADSI query for data
objCommand.CommandText = _
"SELECT givenName,SN,displayName,employeeID,mail," _
& "extensionAttribute1" _
& " FROM 'LDAP://dc=domainname,dc=com' WHERE " _
& "objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objTS.WriteLine objRecordSet.Fields("givenName").Value _
& vbTab & objRecordSet.Fields("SN").Value _
& vbTab & objRecordSet.Fields("displayName").Value _
& vbTab & objRecordSet.Fields("employeeID").Value _
& vbTab & objRecordSet.Fields("mail").Value _
& vbTab & objRecordSet.Fields("extensionAttribute1").Value
objRecordSet.MoveNext
Loop
' close file
objTS.Close
Post new comment