A. The following script generates a list of all the SMTP addresses for enabled users. (You need to modify the strRootDomain variable.)

'                              Option Explicit                              Dim objCommand, objConnection, objChild, objUserConnection, strBase, strFilter, strAttributes,                              strsn, strgivenname,strinitials                              Dim objShell, lngBiasKey, k, PasswordExpiry, strRootDomain, email                              Dim strQuery, objRecordset, strName, strCN                              ' ********************* CHANGE THESE VALUES TO ROOT OF WHERE USERS WILL                              BE SEARCHED ***********************************                              strRootDomain="ou=users,dc=savilltech,dc=net"                              '                              *****************************************************************************************************************************************                              Set objCommand = CreateObject("ADODB.Command")                              Set objConnection = CreateObject("ADODB.Connection")                              objConnection.Provider = "ADsDSOObject"                              objConnection.Open "Active Directory Provider"                              objCommand.ActiveConnection = objConnection                              strBase = "<LDAP://" & strRootDomain & ">"                              strFilter =                              "(&(objectCategory=person)(objectClass=user)(proxyaddresses=*)(!(useraccountcontrol:1.2.840.113556.1.4.803:=2)))"                              strAttributes = "sAMAccountName,cn,distinguishedName,displayname"                              strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"                              objCommand.CommandText = strQuery                              objCommand.Properties("Page Size") = 100                              objCommand.Properties("Timeout") = 30                              objCommand.Properties("Cache Results") = False                              Set objRecordSet = objCommand.Execute                              WScript.echo "Running at " & Date()                              Do Until objRecordSet.EOF                                 strName = objRecordSet.Fields("sAMAccountName").Value                                 Wscript.Echo "Display Name: " & objRecordSet.Fields("displayname").Value                                 Set objUserConnection = GetObject("LDAP://" &                              objRecordSet.Fields
("distinguishedName").Value) For each email in objUserConnection.proxyAddresses If Left (email,5) = "SMTP:" Then WScript.Echo "Primary e-mail address: " & Mid (email,6) ElseIf Left (email,5) = "smtp:" Then WScript.Echo "Seconary e-mail address: " & Mid (email,6) End If Next objRecordSet.MoveNext Loop objConnection.Close

You can change the output format as necessary. Run Cscript listsmtp.vbs.