Configuring Exchange URLs using the Exchange Management Shell

Xavier Mustin

Administrator
Staff member
#1
The Exchange Management Shell also provides the functionality to change the Exchange URLs for each virtual directory, however unless you know the syntax it can be a little intimidating - and even if you do know the relevant syntax, typing each URL can be a little time consuming too.

We can use a PowerShell script to make this process simpler.

The first two lines of the script are used to specify the name of the Exchange 2016 server, in the $Server variable, and the HTTPS name used across all services in the $HTTPS_FQDN variable.

The subsequent lines use this information to correctly set the Internal and External URLs for each virtual directory:

Code:
$Server = "ServerName"

$HTTPS_FQDN = "mail.domain.com"

Get-OWAVirtualDirectory -Server $Server | Set-OWAVirtualDirectory -InternalURL   "https://$($HTTPS_FQDN)/owa" -ExternalURL   "https://$($HTTPS_FQDN)/owa"

Get-ECPVirtualDirectory -Server $Server | Set-ECPVirtualDirectory -InternalURL   "https://$($HTTPS_FQDN)/ecp" -ExternalURL   "https://$($HTTPS_FQDN)/ecp"

Get-OABVirtualDirectory -Server $Server | Set-OABVirtualDirectory -InternalURL   "https://$($HTTPS_FQDN)/oab" -ExternalURL   "https://$($HTTPS_FQDN)/oab"

Get-ActiveSyncVirtualDirectory -Server $Server | Set-ActiveSyncVirtualDirectory -InternalURL "https://$($HTTPS_FQDN)/Microsoft-Server-ActiveSync"   -ExternalURL "https://$($HTTPS_FQDN)/Microsoft-Server-ActiveSync"

Get-WebServicesVirtualDirectory -Server $Server | Set-WebServicesVirtualDirectory -InternalURL "https://$($HTTPS_FQDN)/EWS/Exchange.asmx"   -ExternalURL "https://$($HTTPS_FQDN)/EWS/Exchange.asmx"

Get-MapiVirtualDirectory -Server $Server | Set-MapiVirtualDirectory -InternalURL   "https://$($HTTPS_FQDN)/mapi" -ExternalURL  https://$($HTTPS_FQDN)/mapi
 
Haut