skip to Main Content

Recreate virtual directories in Exchange Server

Today’s article will show how to recreate virtual directories in Exchange Server. After installing Exchange Server and looking in IIS Manager, we can see two sites configured. That’s the Default Web Site and the Exchange Back End. If there are issues and you like to reset virtual directories in Exchange Server, you’re at the right place. Read more on how to recreate virtual directories in Exchange Server.

Find and manage virtual directories in Exchange Server

To find and manage virtual directories, you can use:

  • IIS Manager
  • Exchange Management Shell (EMS)
  • Exchange Admin Center (EAC)

Why you want to recreate Exchange virtual directories

Sometimes you have to start with a clean slate, which will fix most problems. Such as:

  • Permission problems
  • Blank screen
  • Missing files
  • Connectivity issues
  • Page errors

Recreate Exchange virtual directories Default Web Site

Start Internet Information Services (IIS) 6.0 Manager. Exchange Server installation creates two websites:

  • Default Web Site
  • Exchange Back End
Recreate virtual directories in Exchange Server IIS default

To recreate virtual directories in IIS, we will use PowerShell. We will:

  1. Get the virtual directory
  2. Remove the virtual directory
  3. Create the virtual directory

The virtual directories list in alphabetic order:

IIS Virtual DirectoryName

In our example, we will reset the virtual directories on Exchange Server EX01-2016. The internal and external URL is We recommend configuring the internal and external URLs to a generic namespace.

Read more: Exchange namespace design and planning »

Recreate ActiveSyncVirtualDirectory

Run Exchange Management Shell as administrator. Recreate Microsoft-Server-ActiveSync virtual directory.

[PS] C:\>Get-ActiveSyncVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, Identity, InternalUrl, ExternalUrl

Server      : EX01-2016
Name        : Microsoft-Server-ActiveSync (Default Web Site)
Identity    : EX01-2016\Microsoft-Server-ActiveSync (Default Web Site)
InternalUrl :
ExternalUrl :

[PS] C:\>Remove-ActiveSyncVirtualDirectory -Identity "EX01-2016\Microsoft-Server-ActiveSync (Default Web Site)" -Confirm:$false

[PS] C:\>New-ActiveSyncVirtualDirectory -Server "EX01-2016" -InternalUrl "" -ExternalUrl ""

Name                                           Server    InternalUrl
----                                           ------    -----------
Microsoft-Server-ActiveSync (Default Web Site) EX01-2016

Note: Do you get errors when creating the Exchange virtual directory? Read the article An error occurred while creating the IIS virtual directory.

Recreate AutoDiscoverVirtualDirectory

Recreate Autodiscover virtual directory.

[PS] C:\>Get-AutodiscoverVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, Identity

Server   : EX01-2016
Name     : Autodiscover (Default Web Site)
Identity : EX01-2016\Autodiscover (Default Web Site)

[PS] C:\>Remove-AutodiscoverVirtualDirectory -Identity "EX01-2016\Autodiscover (Default Web Site)" -Confirm:$false

[PS] C:\>New-AutodiscoverVirtualDirectory -Server "EX01-2016" -BasicAuthentication $true -WindowsAuthentication $true

Name                            Server    InternalUrl
----                            ------    -----------
Autodiscover (Default Web Site) EX01-2016

[PS] C:\>Set-ClientAccessServer -Identity "EX01-2016" -AutodiscoverServiceInternalUri

Learn more about Autodiscover in Exchange Server:

Recreate EcpVirtualDirectory

Recreate ecp virtual directory.

[PS] C:\>Get-EcpVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, ExternalUrl, Identity

Server      : EX01-2016
Name        : ecp (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\ecp (Default Web Site)

[PS] C:\>Remove-EcpVirtualDirectory -Identity "EX01-2016\ecp (Default Web Site)" -Confirm:$false

[PS] C:\>New-EcpVirtualDirectory -Server "EX01-2016" -InternalUrl "" -ExternalUrl ""

Name                   Server
----                   ------
ecp (Default Web Site) EX01-2016

Recreate MapiVirtualDirectory

Recreate mapi virtual directory.

[PS] C:\>Get-MapiVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, ExternalUrl, Identity

Server      : EX01-2016
Name        : mapi (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\mapi (Default Web Site)

[PS] C:\>Remove-MapiVirtualDirectory -Identity "EX01-2016\mapi (Default Web Site)" -Confirm:$false

[PS] C:\>New-MapiVirtualDirectory -Server "EX01-2016" -InternalUrl -ExternalUrl -IISAuthenticationMethods Ntlm, OAuth, Negotiate

Name                    Server    InternalUrl                 ExternalUrl
----                    ------    -----------                 -----------
mapi (Default Web Site) EX01-2016

Recreate OABVirtualDirectory

Recreate OAB virtual directory.

[PS] C:\>Get-OabVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, ExternalUrl, Identity

Server      : EX01-2016
Name        : OAB (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\OAB (Default Web Site)

[PS] C:\>Remove-OabVirtualDirectory -Identity "EX01-2016\OAB (Default Web Site)" -Confirm:$false -Force

[PS] C:\>New-OabVirtualDirectory -Server "EX01-2016" -InternalUrl "" -ExternalUrl ""
Server    Name                   Internal Url               External Url
------    ----                   ------------               ------------
EX01-2016 OAB (Default Web Site)

Recreate OwaVirtualDirectory

Recreate owa virtual directory.

[PS] C:\>Get-OwaVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, ExternalUrl, Identity

Server      : EX01-2016
Name        : owa (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\owa (Default Web Site)

[PS] C:\>Remove-OwaVirtualDirectory -Identity "EX01-2016\owa (Default Web Site)" -Confirm:$false

[PS] C:\>New-OwaVirtualDirectory -Server "EX01-2016" -InternalUrl "" -ExternalUrl ""

Name                   Server    OwaVersion
----                   ------    ----------
owa (Default Web Site) EX01-2016 Exchange2013

Recreate PowerShellVirtualDirectory

Recreate PowerShell virtual directory.

You must open PowerShell or PowerShell ISE and run the following cmdlets. That’s because you can’t recreate a PowerShell virtual directory if you are in a session (Exchange Management Shell). The first cmdlet will load the Microsoft Exchange Management Powershell Snapin.

PS C:\> Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

PS C:\> Get-PowerShellVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, Externalurl, Identity

Server      : EX01-2016
Name        : Powershell (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\Powershell (Default Web Site)

PS C:\> Remove-PowerShellVirtualDirectory -Identity "EX01-2016\PowerShell (Default Web Site)" -Confirm:$false

PS C:\> New-PowerShellVirtualDirectory -Server "EX01-2016" -Name Powershell -InternalUrl -ExternalUrl -RequireSSL:$false

Name                          Server
----                          ------
Powershell (Default Web Site) EX01-2016

Recreate WebServicesVirtualDirectory

Recreate EWS virtual directory.

[PS] C:\>Get-WebServicesVirtualDirectory -Server "EX01-2016" | Format-List Server, Name, InternalUrl, ExternalUrl, Identity

Server      : EX01-2016
Name        : EWS (Default Web Site)
InternalUrl :
ExternalUrl :
Identity    : EX01-2016\EWS (Default Web Site)

[PS] C:\>Remove-WebServicesVirtualDirectory -Identity "EX01-2016\EWS (Default Web Site)" -Confirm:$false -Force
WARNING: Outlook Web App won't function correctly if you remove the Exchange Web Services virtual directory "EX01-2016\EWS (Default Web Site)". To disable Exchange Web Services without blocking access to Outlook Web
App, you can use "Set-CASMailbox -Identity <user> -EwsEnabled:$false" or "Set-OrganizationConfig -Identity <org> -EwsEnabled:$false".

[[PS] C:\>New-WebServicesVirtualDirectory -Server "EX01-2016" -InternalUrl "" -ExternalUrl ""

Name                   Server    InternalUrl
----                   ------    -----------
EWS (Default Web Site) EX01-2016

Restart IIS or reboot the Exchange Server.

Verify virtual directories in Exchange Admin Center

Start your favorite browser and sign in to Exchange Server Admin Center (EAC). The localhost link is https://localhost/ecp. Next, navigate to servers > virtual directories and select the server on which you recreated the virtual directories.

Recreate virtual directories in Exchange Server EAC

The Exchange virtual directories are recreated and showing successfully. Did it work for you?

Keep reading: Recreate arbitration mailboxes in Exchange Server »


You learned how to recreate virtual directories in Exchange Server. We did reset Exchange virtual directories with PowerShell. The cmdlets did get the virtual directory, remove the virtual directory and, as of last, create the virtual directory. It’s always good to check the virtual directories in Exchange Admin Center to verify if they are created.

Did you enjoy this article? You may also like Recreate audit log mailbox in Exchange Server. Don’t forget to follow us and share this article.



ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 6 Comments

  1. Hi, I am getting the below error on fresh install of exchange 2019 and was going to try to recreate the RPC virtual directory. Is it possible to do that?

    [PS] C:\Windows\system32>Test-OutlookConnectivity -ProbeIdentity Outlook.protocol\OutlookRPCSelfTestProbe
    WARNING: Failed Probe Result Details:

    Error: The remote server returned an error: (403) Forbidden.
    Exception: System.Net.WebException: The remote server returned an error: (403) Forbidden.
    at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.Exchange.RpcClientAccess.Monitoring.VerifyRpcProxyClient.VerifyRpcProxyContext.OnEnd(IAsyncResult
    at Microsoft.Exchange.RpcClientAccess.Monitoring.ClientCallContext`1.InternalEnd(IAsyncResult asyncResult)

  2. Hello,

    I would like to know how to enable HSTS on exchange server 2016 or 2019.
    is it even supported.
    I tried looking around many places , but no concrete information.

    Thank you

  3. Hi Ali,
    I may need your help in a matter of recreating the owa and ecp virtual directories for an exchange2013.
    I removed them, after some errors and reading your amazing guides.
    But when I run the command to recreate the ecp directory it doesn’t do aanything and I do not see it created in IIS and metabase explorer.
    owa seems to be created, but I still get the blank page when I try to login.
    Also the EMC console when I run a command, is very slow in responde and I don’t know why. Sometimes after a command is taking 5-10min and after that nothing, no error, no OK, no response, just the [PS] prompt again.
    Please, I need your help, I don’t know what to do more.

Leave a Reply

Your email address will not be published. Required fields are marked *