MS Exchange 'I am not very good at introducing my Scripts. Let me try here. 'This is a script that loop thru AD and LIST ALL the SMTP addresses for Users or Groups. 'I put this together from my RUS-Helper in response to a NG question 'Deji Akomolafe March 1, 2004 Const ADS_SCOPE_SUBTREE = 2 Const E_ADS_PROPERTY_NOT_FOUND = &H8000500D Set objShell = CreateObject("Wscript.Shell") Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCOmmand.ActiveConnection = objConnection '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''Search for Users ''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''We use this to limit our searches to User accounts only 'uncomment all the lines below 'objCommand.CommandText = _ '"Select distinguishedName from 'LDAP://MyDomainController.MyDomain.com/DC=MyDomain,DC=com' " _ ' & "where objectClass='Person' AND objectcategory='User'" 'If we were looking for a SPECIFIC account, or we are just testing this script out to be sure it's not dangerous 'Then the WHERE clause will read as follows ' & "where objectClass='Person' AND objectcategory='User' AND sAmAccountName='specific_User_Account'" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''Search for Groups ''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''We use this to limit our searches to Group accounts only 'uncomment all the lines below 'objCommand.CommandText = _ '"Select distinguishedName from 'LDAP://MyDomainController.MyDomain.com/DC=MyDomain,DC=com' " _ ' & "where objectClass='Group' AND objectcategory='Group'" 'If we were looking for a SPECIFIC account, or we are just testing this script out to be sure it's not dangerous 'Then the WHERE clause will read as follows ' & "where objectClass='Group' AND objectcategory='Group'" AND sAmAccountName='specific_Group_Account'" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' objCommand.Properties("Page Size") = 1000 objCommand.Properties("Timeout") = 30 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF objUserDN = objRecordSet.Fields("distinguishedName").Value Call GetProxyAddy(objUserDN) objRecordset.MoveNext Loop Set objCOmmand.ActiveConnection = Nothing Set objCommand = Nothing Set objRecordSet = Nothing Set objConnection = Nothing Set objShell = Nothing ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''' Delete the Mailbox ''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub GetProxyAddy(objUserDN) 'Load the other proxy addresses into the property cache Set objCont = GetObject("LDAP://MyDomainController.MyDomain.com/" & objUserDN) 'I could just use GC:// here, but.... objCont.GetInfoEx Array("proxyAddresses"), 0 On Error Resume Next varAddrs = objCont.GetEx("proxyAddresses") 'Now, we are going to loop through each of the email addresses associated with the User in AD For each email in varAddrs Wscript.Echo email Next 'Clean up Set objCont = Nothing End Sub ''''''''''''''''''''''''''''''''''' '''''''''' The End '''''''''''''''' '''''''''''''''''''''''''''''''''''