Exchange 2003 Relay-IPs ermitteln und in Exchange 2010 Receive Connector importieren

Mit einem kleinen Script kann man die IPs oder IP Ranges des SMTP Dienstes vom Exchange 2003 auslesen und direkt in einen entsprechenden Receive Connector auf Exchange 2010 importieren.

Vor Verwendung des Scripts bitte an die eigene Umgebung anpassen und testen!

Dim objSMTP,objRelayIpList,objCurrentList,objIP
Dim objFSO,objTextFile,count,newIpList(),inputOption,IPTxtPath
Set objSMTP = GetObject("IIS://localhost/smtpsvc/1")
Set objRelayIpList = objSMTP.Get("RelayIpList")
'***objRelayIpList is of type IIsIPSecuritySetting 
'***http://msdn.microsoft.com/en-us/library/ms525725.aspx
if objRelayIpList.GrantByDefault = TRUE then
  objCurrentList = objRelayIPList.IPDeny
else
 objCurrentList = objRelayIPList.IPGrant
end if 
Set objRelay = GetObject("LDAP://CN=Relay Connector,CN=SMTP Receive Connectors," _
                           "CN=Protocols,CN=yourServer,CN=Servers," _
                           "CN=Exchange Administrative Group (FYDIBOHF23SPDLT)," _ 
                           "CN=Administrative Groups,CN=YourOrg,CN=Microsoft Exchange," _
                           "CN=Services,CN=Configuration,DC=YourDomain,DC=YourDomain,DC=net")
For each ip in objCurrentList
 aIP = split(ip,",")
 if aIP(1)=" 255.255.255.255" then '*** einzelne IP Adresse/Host
 cIP=trim(aIP(0))
 else
 cIP = trim(aIP(0)) & "(" & trim(aIP(1)) & ")" '*** sonst Subnetz
 end if
 '*** Debug Info: msgbox IP & vbCRLF & cIP
 objRelay.PutEx 3, "msExchSmtpReceiveRemoteIPRanges", array(cIP)
 objRelay.SetInfo
next