This script is a mutation of yesterday’s script.
It searches Active Directory for mail enabled groups with multiple smtp addresses.
By changing the treshold value (i) in line number 39 you can broaden or narrow your searches.
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:tempshowgroupswithmultiplesmtp.vbs)
* open a command prompt
* go to “c:temp”
* give “cscript showgroupswithmultiplesmtp.vbs” (without quotes) and enter
The script:
' Name : showgroupswithmultiplesmtp.vbs
' Description : script to show all groups with multiple smtp addresses
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 23-02-2010
' Level : intermediate
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=group)(mail=*))"
strAttributes = "distinguishedName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
On Error Resume Next
Set objGroup = GetObject ("LDAP://" & adoRecordset.Fields("distinguishedName").Value)
arrProxy = objGroup.GetEx("proxyAddresses")
i = 0
For Each strMailAddress in arrProxy
If Lcase(Left(strMailAddress,5))= "smtp:" Then
i = i + 1
End If
Next
If i >= 2 Then
strAllMailAddresses = ""
For Each strMailAddress in arrProxy
If Lcase(Left(strMailAddress,5))= "smtp:" Then
strAllMailAddresses = strAllMailAddresses & " ; " & strMailAddress
End If
Next
Wscript.Echo objGroup.DisplayName & strAllMailAddresses
End If
Set objGroup = Nothing
adoRecordset.MoveNext
Loop
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.
I also added a rating system yesterday, thank you in advance for your reaction.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
