Convert Exchange Mailboxes to Mail Enabled Remote users

This script was used as part of Exchange 2010 migration to Office 365.  No hybrid was used and mailboxes had already been created in 365.  This script creates another powershell script that can be examined and executed.  The Powershell script removes the on premise mailbox, takes note of the SMTP addresses and re-creates as a remote user.  To run this in manageable batches set the Exchange CutomAttribute1 field to “migrate” no quotes.

$mailboxes = Get-mailbox | where {$_.CustomAttribute1 -eq "migrate"}
  $file = "c:\temp\run.ps1"

out-file $file

foreach ($mailbox in $mailboxes) {

$alias = $mailbox.alias
  $samaccountname = $mailbox.samaccountname
  $emailaddresses = $mailbox.emailaddresses -split ","
  $primarysmtpaddress = $mailbox.primarysmtpaddress

"disable-mailbox $alias -Confirm:`$true" | out-File $file -append

foreach ($emailaddress in $emailaddresses) {

if ($emailaddress.contains("companyabc.onmicrosoft.com") ) {

$email = ($emailaddress.replace("smtp:","")).replace("SMTP:","")
  "enable-remotemailbox $samaccountname -primarySmtpAddress $primarysmtpaddress -remoteroutingaddress $email" | out-File $file -append

}

}

foreach ($emailaddress in $emailaddresses) {

if ( $emailaddress.toupper().contains("SMTP:") -and !$emailaddress.contains("onmicrosoft.com") ){

$email = ($emailaddress.replace("smtp:","")).replace("SMTP:","")
  "set-remotemailbox $samaccountname -emailaddresses @{add='$email'}" | out-File $file -append
  }
  }

}

Using Outlook Anywhere with multiple domains and a single SSL certificate

I had a customer with a primary SMTP domain but a couple others for certain individuals within the business. The SSL cert was a wildcard bound to the primary SMTP domain and Autodiscover/ Outlook configuration would fail for other SMTP domain logons.

I read various articles on changing IIS for redirects etc
http://www.msexchange.org/articles-tutorials/exchange-server-2010/management-administration/exchange-autodiscover.html
http://www.msexchange.org/articles-tutorials/exchange-server-2010/mobility-client-access/using-autodiscover-large-numbers-accepted-domains-part1.html

However I found the simplest solution was to remove the autodiscover A record for the secondary domains (internal & external) and replace with a single SRV record pointing back to the primary domain.

Service: _autodiscover
Protocol: _tcp
Port Number: 443
Host: mail.primary.com
Priority: 0
Weight: 0

http://markgossa.blogspot.co.uk/2015/11/exchange-2013-2016-autodiscover-with-multiple-domains-and-single-name-certificate.html

 

Exchange 2016 – Adding an internal relay

This is different process than Exchange 2013 and earlier;

How to Configure Exchange Server 2016 for SMTP Application Relay