Today’s script gives you almost all user details that are visible in Outlook.
It is tested with Exchange-Outlook 2003.
The script itself is a regular ADO query only pimped with a lot of attributes (19 to be precisely).
Follow the next steps to run the script (no admin rights needed):
* open your favorite text editor
* copy and paste the script into the editor
* save the script (for example c:tempoutlookdetails.vbs)
* open a command prompt
* go to “c:temp”
* give “cscript outlookdetails.vbs” (without quotes) and enter
The script:
' Name : outlookdetails.vbs
' Description : script to enumerate the Outlook details of all users in your company
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 09-02-2010
' Level : intermediate
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strUserDN, objUser, protocolSettings, strUser
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
' Filter on user objects.
strFilter = "(&(objectCategory=person)(objectClass=user))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "mail,givenname,initials,sn,displayname,mailNickname,postalAddress,title,company,l,department,
st,streetAddress,postalCode,co,telephoneNumber,mobile,info,physicalDeliveryOfficeName"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
If adoRecordset.Fields("mail").Value <> "" Then
If Left(adoRecordset.Fields("mail").Value, 13) <> "SystemMailbox" Then
wscript.echo adoRecordset.Fields("mail").Value &_
";" & adoRecordset.Fields("givenname").Value &_
";" & adoRecordset.Fields("initials").Value &_
";" & adoRecordset.Fields("sn").Value &_
";" & adoRecordset.Fields("displayname").Value &_
";" & adoRecordset.Fields("mailNickname").Value &_
";" & adoRecordset.Fields("postalAddress").Value &_
";" & adoRecordset.Fields("title").Value &_
";" & adoRecordset.Fields("company").Value &_
";" & adoRecordset.Fields("l").Value &_
";" & adoRecordset.Fields("department").Value &_
";" & adoRecordset.Fields("st").Value &_
";" & adoRecordset.Fields("streetAddress").Value &_
";" & adoRecordset.Fields("postalCode").Value &_
";" & adoRecordset.Fields("co").Value &_
";" & adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
";" & adoRecordset.Fields("telephoneNumber").Value &_
";" & adoRecordset.Fields("mobile").Value &_
";" & adoRecordset.Fields("info").Value
End If
End If
'Move to the next record in the recordset.
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
When you have problems/questions please post a reply.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV

[...] today it is modification day. This script is a modification of the previous outlook details script. The modification is in the filter at line number 25: the filter attribute userAccountControl with [...]