'Global variables
Dim Container
Dim OutPutFile
Dim FileSystem
 
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("smtpaddresses.csv", True)
 
'Replace with valid DN of the container you want to enumerate
Set Container=GetObject("LDAP://DC=EXAMPLE_DOMAIN,DC=com")
 
'Enumerate Container
EnumerateUsers Container
 
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set Container = Nothing
 
'Say Finished when your done
WScript.Echo "Finished"
WScript.Quit(0)
 
'List all Users
Sub EnumerateUsers(Cont)
Dim User
 
'Go through all Users and select them
For Each User In Cont
Select Case LCase(User.Class)
 
'If you find Users
Case "user"
  'Select all proxyAddresses
  Dim Alias
  If Not IsEmpty(User.proxyAddresses) Then
    'OutPutFile.Write User.DisplayName
    For Each Alias in User.proxyAddresses
      If InStr(1,Alias,"smtp",1) > 0 Then
            OutPutFile.WriteLine User.SN & ", " & User.givenName & ", " & User.l & ", " & User.st & ", " & User.postalCode & ", " & User.DisplayName & ", " & User.telephoneNumber & ", " & User.mobile & ", " & Replace(Alias,"smtp:","",1,1,1)
            'WScript.Echo User.DisplayName & ", " & Replace(Alias,"smtp:","",1,1,1)
        End If
    'WScript.Echo Alias
      Next
  End If
 
Case "organizationalunit" , "container"
  EnumerateUsers User
 
End Select
Next
End Sub

 

Save as GAL.vb edit file and run

Comments:

Leave a Reply



(Your email will not be publicly displayed.)

Please type the letters and numbers shown in the image.Captcha Code