If you want to change Mapi, Autodiscover / EWS / OAB / OWA / ECP / Activesync Url, this is how it works
Example you have bought a certificate on you external name, and now you got certificate warnings in outlook.
set-MapiVirtualDirectory -id "SERVERNAME\mapi (Default Web Site)" -internalurl https://owa.domain.prefix/mapi -externalurl https://owa.domain.prefix/mapi
Set-WebServicesVirtualDirectory -Identity "SERVERNAME\EWS (Default Web Site)" -InternalUrl https://owa.domain.prefix/EWS/Exchange.asmx -externalurl https://owa.domain.prefix /EWS/Exchange.asmx -BasicAuthentication:$true
Set-AutoDiscoverVirtualDirectory -Identity "SERVERNAME\Autodiscover (Default Web Site)" -internalurl https://owa.domain.prefix/autodiscover/autodiscover.xml -externalurl https://owa.domain.prefix/autodiscover/autodiscover.xml
set-OabVirtualDirectory -identity "SERVERNAME\OAB (Default Web Site)" -internalurl https://owa.domain.prefix/OAB -externalurl https://owa.domain.prefix/OAB
set-EcpVirtualDirectory -identity "SERVERNAME\ecp (Default Web Site)" -internalurl https://owa.domain.prefix/ecp -externalurl https://owa.domain.prefix/ecp
set-OwaVirtualDirectory -identity "SERVERNAME\owa (Default Web Site)" -internalurl https://owa.domain.prefix/owa -externalurl https://owa.domain.prefix/owa
set-ActiveSyncVirtualDirectory -identity "SERVERNAME\Microsoft-Server-ActiveSync (Default Web Site)" -internalurl https://owa.domain.prefix/Microsoft-Server-ActiveSync -externalurl https://owa.domain.prefix/Microsoft-Server-ActiveSync
Set-ClientAccessServer -Identity "SERVERNAME" –AutoDiscoverServiceInternalUri https://owa.domain.prefix/autodiscover/autodiscover.xml
iisreset
Or if this is a single server installation you can do it like this: (Or if you want all servers to use the same URL
get-mapivirtualdirectory | set-MapiVirtualDirectory -internalurl https://owa.domain.prefix/mapi -externalurl https://owa.domain.prefix/mapi
get-WebServicesVirtualDirectory | Set-WebServicesVirtualDirectory -InternalUrl https://owa.domain.prefix/EWS/Exchange.asmx -externalurl https://owa.domain.prefix/EWS/Exchange.asmx -BasicAuthentication:$true
get-AutoDiscoverVirtualDirectory | Set-AutoDiscoverVirtualDirectory -internalurl https://owa.domain.prefix/autodiscover/autodiscover.xml -externalurl https://owa.domain.prefix/autodiscover/autodiscover.xml
get-OabVirtualDirectory | set-OabVirtualDirectory -internalurl https://owa.domain.prefix/OAB -externalurl https://owa.domain.prefix/OAB
get-EcpVirtualDirectory | set-EcpVirtualDirectory -internalurl https://owa.domain.prefix/ecp -externalurl https://owa.domain.prefix/ecp
get-OwaVirtualDirectory | set-OwaVirtualDirectory -internalurl https://owa.domain.prefix/owa -externalurl https://owa.domain.prefix/owa
get-ActiveSyncVirtualDirectory | set-ActiveSyncVirtualDirectory -internalurl https://owa.domain.prefix/Microsoft-Server-ActiveSync -externalurl https://owa.domain.prefix/Microsoft-Server-ActiveSync
get-ClientAccessServer | Set-ClientAccessServer –AutoDiscoverServiceInternalUri https://owa.domain.prefix/autodiscover/autodiscover.xml
iisreset