Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to get SMTP server?

Status
Not open for further replies.

FK122

Programmer
May 6, 2005
6
CA
Hi guys,

I need to grab the SMTP mail server somehow. The machines the script will be run on are operating Outlook 2002, so I figure there's probably a registry entry somewhere that has the mail server, but I just don't know where. Or, perhaps there's an easier way :) Any ideas?

Thanks,
FK
 
This information is in AD. It is in the attribute msExchHomeServerName for each user object. This will enumerate the AD tree and return the name and Mailserver for each user.

'****************Setup ADSI connection and populate ADSI Collection************************************************

Set objADOconnADSI = CreateObject("ADODB.Connection")
objADOconnADSI.Open "Provider=ADsDSOObject;"
Set objCommandADSI = CreateObject("ADODB.Command")
objCommandADSI.ActiveConnection = objADOconnADSI
objCommandADSI.Properties("Size Limit")= 10000
objCommandADSI.Properties("Page Size")= 10000
objCommandADSI.Properties("Sort on") = "name"
objCommandADSI.CommandText = "<LDAP://saws.org>;(objectClass=user);" & _
"name,distinguishedname,msExchHomeServerName;subtree"
Set objRSADSI = objCommandADSI.Execute
do while NOT objRSADSI.EOF
if not isnull(objRSADSI.fields("msExchHomeServerName")) then
ExServer = right(objRSADSI.fields("msExchHomeServerName"),_
len(objRSADSI.fields("msExchHomeServerName"))_
-InStrRev(objRSADSI.fields("msExchHomeServerName"),"="))
wscript.echo objRSADSI.fields("name") & " - " & ExServer
end if
objRSADSI.MoveNext
loop
wscript.echo "Done!"


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top