In this article, I am going to configure virtual directories in Exchange 2019. I will configure internal and external URLs in Exchange Server 2019. Configuring the virtual directory URLs can be done using PowerShell or the Exchange Admin Center (EAC). Well, nearly all parts can be configured via EAC, because some roles (AutoDiscover, Outlook Anywhere) need to be configured with PowerShell. By following this article, you will be an expert in configuring URLs in Exchange Server.
How to setup internal and External URLs in Exchange using PowerShell
Sign in with your Exchange server and run Exchange Management Shell as an administrator. Configure the virtual directory URL for every component, and then verify it. If you would like to set your URLs on all the Exchange Servers, replace your Exchange Server name in each command.
In this scenario, we have to configure URLs on this specific Exchange Server, which is why we will use the server parameter. Microsoft Exchange server PowerShell script to configure virtual directories.
External and Internal URL Virtual Directories Setup in Exchange Server 2019
Table of Contents
Configure Virtual Directories in Exchange 2019
Log in with your Exchange server in the Exchange Admin Center and go to servers and virtual directories.
Select Microsoft-Server-ActiveSync (Default Web Site) and then select the setting icon.

On the Configure External Access Domain page, select the Add + button.

Choose the Exchange EX2019-01 server on which you want to configure external URLs. Select the Add button, and then click OK.

Type the domain name you want to use externally. In this lab, I need our external users to go to mail.jamiltech.com. Click Save to configure virtual directories in Exchange.

Once completed, just click close.

ECP Virtual Directory PowerShell
Run exchange management shell
Type this command and hit enter.
Set-EcpVirtualDirectory -Identity “EX2019-01\ECP (Default Web Site)” -ExternalUrl https://mail.jamiltech.com/ecp -InternalUrl https://mail.jamiltech.com/ecp

To verify the ECP virtual directory configuration, run the following command:.
Get-EcpVirtualDirectory | Select Server,ExternalURL,InternalURL | fl

ECP Virtual Directory GUI
In Exchange Admin Center, select the servers option and select the Virtual Directories tab.
Select ECP (Default Web Site) and then select the edit button.

In general, enter internal and external URLs, and then click save.

OWA Virtual Directory PowerShell
Type this command to set an OWA virtual directory.
Set-OWAVirtualDirectory -identity “EX2019-01\owa (Default Web Site)” -InternalURL https://mail.jamiltech.com/owa -ExternalURL https://mail.jamiltech.com/owa

To verify the OWA URL virtual directory, run the below command.
Get-OwaVirtualDirectory | Select Server,ExternalURL,InternalURL | fl

OWA Virtual Directory GUI
In the Virtual Directories, select OWA (Default Web Site) and then select the edit button.

Enter OWA’s internal and external URLs, and then click Save.

ActiveSync Virtual Directory PowerShell
Type this PowerShell command to set the ActiveSync virtual directory.
Set-ActiveSyncVirtualDirectory -Identity “EX2019-01\Microsoft-Server-ActiveSync (Default Web Site)” -ExternalUrl https://mail.jamiltech.com/Microsoft-Server-ActiveSync -InternalUrl https://mail.jamiltech.com/Microsoft-Server-ActiveSync

To verify the active sync virtual directory configuration, type the below command.
Get-ActiveSyncVirtualDirectory | select server,externalurl,internalurl | fl

ActiveSync Virtual Directory PowerShell
Under the Virtual Directories tab, click on Microsoft Server ActiveSync (Default Web Site), and then click on the edit button.

On the General tab, set the internal and external URLs, and then click save.

OAB Virtual Directory PowerShell
Type the following command to set the OAB virtual directory:.
Set-OabVirtualDirectory -Identity “EX2019-01\OAB (Default Web Site)” -ExternalUrl https://mail.jamiltech.com/OAB -InternalUrl https://mail.jamiltech.com/OAB

To verify the configuration of the OAB virtual directory URL, run the following command:.
Get-OabVirtualDirectory | Select Server,ExternalURL,InternalURL | fl

OAB Virtual Directory GUI
In the Virtual Directories tab, click on OAB (Default Web Site) and then choose the edit button.

Set the internal and external URLs, and then click Save.

Exchange Web Services Virtual Directory PowerShell
Run the following command to set the Exchange Web Services virtual directory:.
Set-WebServicesVirtualDirectory -Identity “EX2019-01\EWS (Default Web Site)” -ExternalUrl https://mail.jamiltech.com/EWS/Exchange.asmx -InternalUrl https://mail.jamiltech.com/EWS/Exchange.asmx

To verify the web services virtual directory URL configuration, run the following cmdlet:.
Get-WebServicesVirtualDirectory | Select Server,ExternalURL,InternalURL | fl

Exchange Web Services Virtual Directory GUI
In the Virtual Directories settings, click on the EWS URL (Default Web Site) and then select the edit button.

Enter EWS’s internal and external URLs, and then click Save.

PowerShell Virtual Directory
In the Virtual Directories tab, click on PowerShell (Default Web Site) and then select the edit button.

Type the PowerShell virtual directory internal and external URLs, and then click save.

Related: How to Backup and Restore Exchange Database
Read this article to learn more about how to set up virtual directories in Exchange Server.