To perform this task, we'll first set two variables to define the source and target servers:

$OldServer = "OldServer"

$NewServer = "NewServer"

Then, we'll retrieve the list of non-default Receive Connectors from the source server into the variable$ReceiveConnectors:

[array]$ReceiveConnectors = Get-ReceiveConnector -Server $OldServer | Where {$_.Name -notlike "Default $($OldServer)" -and $_.Name -notlike "Client $($OldServer)"}

 

To create the Receive Connectors on the target server, we can use a foreach loop to create new receive connectors, populating the values from the source. Before we actually make any changes, we'll run the commands with the -WhatIfswitch to check the syntax and the validity of the command:

$ReceiveConnectors | foreach {

New-ReceiveConnector -Name $_.Name -RemoteIPRanges $_.RemoteIPRanges -bindings $_.Bindings-Banner $_.Banner -ChunkingEnabled $_.ChunkingEnabled -DefaultDomain $_.DefaultDomain -DeliveryStatusNotificationEnabled $_.DeliveryStatusNotificationEnabled -EightBitMimeEnabled$_.EightBitMimeEnabled -DomainSecureEnabled $_.DomainSecureEnabled -LongAddressesEnabled$_.LongAddressesEnabled -OrarEnabled $_.OrarEnabled -Comment $_.Comment -Enabled $_.Enabled-ConnectionTimeout $_.ConnectionTimeout -ConnectionInactivityTimeout$_.ConnectionInactivityTimeout -MessageRateLimit $_.MessageRateLimit -MaxInboundConnection$_.MaxInboundConnection -MaxInboundConnectionPerSource $_.MaxInboundConnectionPerSource -MaxInboundConnectionPercentagePerSource $_.MaxInboundConnectionPercentagePerSource -MaxHeaderSize $_.MaxHeaderSize -MaxHopCount $_.MaxHopCount -MaxLocalHopCount$_.MaxLocalHopCount -MaxLogonFailures $_.MaxLogonFailures -MaxMessageSize $_.MaxMessageSize-MaxProtocolErrors $_.MaxProtocolErrors -MaxRecipientsPerMessage $_.MaxRecipientsPerMessage-PermissionGroups $_.PermissionGroups -PipeliningEnabled $_.PipeLiningEnabled -ProtocolLoggingLevel $_.ProtocolLoggingLevel -RequireEHLODomain $_.RequireEHLODomain -RequireTLS $_.RequireTLS -EnableAuthGSSAPI $_.EnableAuthGSSAPI -ExtendedProtectionPolicy$_.ExtendedProtectionPolicy -ExtendedProtectionTlsTerminatedAtProxy$_.ExtendedProtectionTlsTerminatedAtProxy -SizeEnabled $_.SizeEnabled -TarpitInterval$_.TarpitInterval -Server $NewServer -WhatIf

}