LDAP style sync for O365 mailboxes with 3rd party filter. Also sets up required inbound and outbound connectors.
To automate the connector initial setup, integrate the lockdown rules with below Powershell code:
param( [string]$arg1, [string]$arg2 )
allows ps to be run without needing to be signed - 1 time call that needs to be run to update server settings
$User = $arg2 ### '[email protected]' ### $arg2 $PWord = ConvertTo-SecureString -String $arg1 -AsPlainText -Force ### "XXXXX" ### $arg1
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential ${Credential} -Authentication Basic -AllowRedirection Import-PSSession $Session –AllowClobber
New-TransportRule "Filter lockdown" -RejectMessageReasonText "Email bypassed MX records" -RejectMessageEnhancedStatusCode "5.7.1" -ExceptIfMessageTypeMatches Calendaring -ExceptIfSenderIpRanges '1.1.1.1/32', '2.2.2.2/20', '3.3.3.3/24' -ExceptIfFromScope InOrganization
New-OutboundConnector "Filter Outbound" -RecipientDomains * -UseMXRecord $false -SmartHosts "outbound.address.com" -TlsSettings EncryptionOnly
Validate-OutboundConnector -Identity "Filter Outbound" -Recipients [email protected]