Issue: You need to efficiently change all the internal URL’s on an Exchange server to the value of the External URL.
Background: This is a common necessity when your internal AD domain name has a .local and/or cannot be included in the SSL certificate on the Exchange server. This article applies to Exchange 2010, 2013 and 2016. It may also work on Exchange 2007 but I have not tested it.
Solution: Using Exchange Management Shell we can populate all of the internal URL fields using the data in the External URL field in Exchange.
Copy the following PowerShell commands into notepad on your exchange server and edit the “$HostName=” to be the name of your Exchange server.
$HostName=”exchangeservername.addomainname.local”
Set-EcpVirtualDirectory “$HostName\ECP (Default Web Site)” -InternalUrl ((Get-EcpVirtualDirectory “$HostName\ECP (Default Web Site)”).ExternalUrl)
Set-WebServicesVirtualDirectory “$HostName\EWS (Default Web Site)” -InternalUrl ((get-WebServicesVirtualDirectory “$HostName\EWS (Default Web Site)”).ExternalUrl)
Set-ActiveSyncVirtualDirectory “$HostName\Microsoft-Server-ActiveSync (Default Web Site)” -InternalUrl ((Get-ActiveSyncVirtualDirectory “$HostName\Microsoft-Server-ActiveSync (Default Web Site)”).ExternalUrl)
Set-OabVirtualDirectory “$HostName\OAB (Default Web Site)” -InternalUrl ((Get-OabVirtualDirectory “$HostName\OAB (Default Web Site)”).ExternalUrl)
Set-OwaVirtualDirectory “$HostName\OWA (Default Web Site)” -InternalUrl ((Get-OwaVirtualDirectory “$HostName\OWA (Default Web Site)”).ExternalUrl)
Set-PowerShellVirtualDirectory “$HostName\PowerShell (Default Web Site)” -InternalUrl ((Get-PowerShellVirtualDirectory “$HostName\PowerShell (Default Web Site)”).ExternalUrl)
Review the powershell commands to verify they make sense to you for your situation.
Paste your completed commands as an entire block into the Exchange Management Shell on your Exchange server. The commands will run one after the other. I’ve found sometimes I have to hit enter if the commands are paused.