Skip to content

Instantly share code, notes, and snippets.

@mardahl
Last active October 7, 2020 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mardahl/8e22c5ca71f95cb616a45f0db36bc78c to your computer and use it in GitHub Desktop.
Save mardahl/8e22c5ca71f95cb616a45f0db36bc78c to your computer and use it in GitHub Desktop.
Create exchange send connector for relaying through exchange online protection
#This script will create a send connector that can relay through exchange online protection in Office 365
#Must be run from the on prem Exchange Management Shell
#WARNING: This will use the wildcard * for sending, so please consider changing "addressSpaces" to some testing domains, so you know this works before routing everything.
#WARNING: You must remove your existing internet send connector if you wish for this to work with 100% of all email.
#Author: @michael_mardahl (github.com/mardahl)
#License: MIT - please keep author credits.
$hybridConnector = Get-SendConnector *365*
$smartHost = Resolve-DnsName $hybridConnector.AddressSpaces.Address -Type MX
New-SendConnector -Name EOP-Smarthost -AddressSpaces * -CloudServicesMailEnabled $true -Fqdn $hybridConnector.Fqdn -RequireTLS $true -DNSRoutingEnabled $false -SmartHosts $smartHost.NameExchange -TlsAuthLevel CertificateValidation -Usage Internet -TlsCertificateName $hybridConnector.TlsCertificateName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment