Thursday, June 4, 2015

Creating Identical Receive And Send Connectors


Hi folks,

I would love to share with you about an easy way to create receive connectors for multiple transport servers (Mailbox servers in Exchange 2013). As you know receive connectors are maintained on per server basis. At the other hand to have consistent mail receive experience you will need to have identical configuration of receive connectors in your organization, This task will be hard if you have many Exchange servers.

But fortunately, PowerShell is indeed powershell and allows to automate this task. All you need to do is to create one receive connector on first transport (mailbox) server and then you can easily deploy them across.

I won't share how to create receive connector as you can read about it in this TechNet article.

After receive connector is created you create a variable and dump all the information about the connector there. Then you run New-Receive connector on the rest of the server using New-receiveConnector cmdlet (or lately tweaking them using Set-ReceiveConnector cmdlet) and get all the necessary values for the parameters from the respective parameters dumped into the variable. The code will be as follows.

$RC = Get-ReceiveConnector -Identity "SERVER001\MyConnector"

For Exchange 2010:

New-ReceiveConnector -Name "MyConnector" -Server SERVER002 -AuthMechanism $RC.AuthMechanism -Bindings $RC.Bindings -Enabled $RC.Enabled -ConnectionInactivityTimeout $RC.ConnectionInactivityTimeout -ConnectionTimeout $RC.ConnectionTimeout -MessageRateSource $RC.MessageRateSource -MaxInboundConnection $RC.MaxInboundConnection -MaxInboundConnectionPerSource $RC.MaxInboundConnectionPerSource -MaxInboundConnectionPercentagePerSource $RC.MaxInboundConnectionPercentagePerSource -MaxRecipientsPerMessage $RC.MaxRecipientsPerMessage -PermissionGroups $RC.PermissionGroups -ProtocolLoggingLevel $RC.ProtocolLoggingLevel -RemoteIPRanges $RC.RemoteIPRanges -MaxMessageSize $RC.MaxMessageSize -MaxHopCount $RC.MaxHopCount -MaxLocalHopCount $RC.MaxLocalHopCount

For Exchange 2013:

New-ReceiveConnector -Name "My Connector" -Server SERVER002 -AuthMechanism $RC.AuthMechanism -Bindings $RC.Bindings -Enabled $RC.Enabled -ConnectionInactivityTimeout $RC.ConnectionInactivityTimeout -ConnectionTimeout $RC.ConnectionTimeout -MessageRateSource $RC.MessageRateSource -MaxInboundConnection $RC.MaxInboundConnection -MaxInboundConnectionPerSource $RC.MaxInboundConnectionPerSource -MaxInboundConnectionPercentagePerSource $RC.MaxInboundConnectionPercentagePerSource -MaxRecipientsPerMessage $RC.MaxRecipientsPerMessage -PermissionGroups $RC.PermissionGroups -ProtocolLoggingLevel $RC.ProtocolLoggingLevel -RemoteIPRanges $RC.RemoteIPRanges -MaxMessageSize $RC.MaxMessageSize -MaxHopCount $RC.MaxHopCount -MaxLocalHopCount $RC.MaxLocalHopCount -TransportRole $RC.TransportRole

Even more automation can be achieved if you create another variable for transport servers and then run New-ReceiveConnector cmdlet against every transport server in this variable, like below:

$TS = Get-TransportServer (for Exchange 2010)
or
$TS = Get-MailboxServer (for Exchange 2013 and later)

and then

$TS | foreach {New-ReceiveConnector -Name "MyConnector" -Server $_.Name -AuthMechanism $RC.AuthMechanism -Bindings $RC.Bindings -Enabled $RC.Enabled -ConnectionInactivityTimeout $RC.ConnectionInactivityTimeout -ConnectionTimeout $RC.ConnectionTimeout -MessageRateSource $RC.MessageRateSource -MaxInboundConnection $RC.MaxInboundConnection -MaxInboundConnectionPerSource $RC.MaxInboundConnectionPerSource -MaxInboundConnectionPercentagePerSource $RC.MaxInboundConnectionPercentagePerSource -MaxRecipientsPerMessage $RC.MaxRecipientsPerMessage -PermissionGroups $RC.PermissionGroups -ProtocolLoggingLevel $RC.ProtocolLoggingLevel -RemoteIPRanges $RC.RemoteIPRanges -MaxMessageSize $RC.MaxMessageSize -MaxHopCount $RC.MaxHopCount -MaxLocalHopCount $RC.MaxLocalHopCount}

Similar approach can be used for cloning send connectors in case you want to create scoped send connector or create send connector that use different source hub or mailbox servers in different sites.
The code for this will be as below:


$SC = Get-SendConnector "Send Connector Russia"

New-SendConnector "Send Connector Poland" -AddressSpaces $SC.AddressSpaces  -ConnectionInactivityTimeOut $SC.ConnectionInactivityTimeOut -DNSRoutingEnabled $SC.DNSRoutingEnabled -Enabled $SC.Enabled -ForceHELO $SC.ForceHELO -IgnoreSTARTTLS $SC.IgnoreSTARTTLS -MaxMessageSize $SC.MaxMessageSize -SourceTransportServers SERVER001,SERVER002 -SmartHosts $SC.SmartHosts -SmartHostAuthMechanism $SC.SmartHostAuthMechanism

Enjoy.