Site icon Franky's Web

Exchange 2016: Create new virtual directories in IIS

Although the virtual directories for the various Exchange web services can be recreated via the "Exchange Admin Center", there are cases where this function reaches its limits.

I simulated such an error for this article. Even after resetting the directory for OWA with the Exchange Admin Center, OWA does not work:

Not everything can be done with the GUI.

Introduction

Exchange 2016 has two websites in the IIS. The "Default Web Site" website contains the Client Access service, which no longer exists as a separate Exchange role, but is still present. Exchange clients, such as Outlook and smartphones, connect to the virtual directories within the "Default Web Site". The virtual directories within the "Default Web Site" therefore form the front end for the clients/protocols.

The front end serves the clients as a proxy for the "Exchange back end", which has its own website within the IIS. The back end contains the actual logic, the front end only serves as a stateless proxy. The following screenshot shows the two websites:

The virtual directories can also be displayed in the Exchange Management Shell, for example the following command shows the virtual directory for OWA:

Get-OwaVirtualDirectory -Server TEX1

However, the command only displays the front end, which can be recognized by the "Name" parameter: Default Web Site. The following command can be used so that the corresponding counterpart is also displayed in the back end:

Get-OwaVirtualDirectory -Server TEX1 -ShowMailboxVirtualDirectories

The following command can be used to obtain a list of all corresponding commands for listing the virtual directories:

get-command get-*VirtualDirectory

So much for the theory for now. Various problems may make it necessary to recreate one or more of the virtual directories.

Create new virtual directories

This small example shows the creation of a new virtual directory for Outlook Web Access (Outlook on the Web, OWA). To simulate an error, I have simply deleted the virtual directory for OWA in the "Default Web Site" and in the "Exchange Back End" web page for this article:

Deleting the two directories then leads to an HTTP 404 error:

In my case, I now have to create new front-end and back-end directories for OWA. However, I have only deleted the directories in IIS. Exchange still assumes that the front-end and back-end exist. This can be checked with the following command:

Get-OwaVirtualDirectory -Server TEX1 -ShowMailboxVirtualDirectories

In this screenshot you can see that the OWA directory is missing in the IIS, but is still displayed in the Exchange Shell:

Exchange saves its part of the configuration in the Active Directory, as can be seen here:

So that the OWA front-end and back-end can be recreated, the directories must first be deleted from the Exchange configuration. The following command can be used for this:

Get-OwaVirtualDirectory -Server TEX1 -ShowMailboxVirtualDirectories | Remove-OwaVirtualDirectory

In principle, you could now recreate the directory for OWA if it were not for the IIS metabase. There are also entries here that prevent the virtual directory from being recreated. As a rule, the following error occurs if an attempt is made to recreate the OWA directory and there are remnants in the IIS metabase:

Fehler beim Erstellen des virtuellen IIS-Verzeichnisses ‚IIS://TEX1.frankysweb.local/W3SVC/1/ROOT/owa‘ auf ‚TEX1‘.
+ CategoryInfo : InvalidOperation: (TEX1\owa (Default Web Site):ADObjectId) [New-OwaVirtualDirectory], In
validOperationException
+ FullyQualifiedErrorId : [Server=TEX1,RequestId=a96fe949-f9e2-48b1-977d-e7a5f8cbc600,TimeStamp=18.10.2017 18:43:5
1] [FailureCategory=Cmdlet-InvalidOperationException] 5812692E,Microsoft.Exchange.Management.SystemConfigurationTa
sks.NewOwaVirtualDirectory
+ PSComputerName : tex1.frankysweb.local

To clean up the corpses in the IIS Metabase, the rather old tool "IIS Metabase Explorer" can be used. The tool can be downloaded here:

The "IIS Metabase Explorer" requires .NET Framework 3.5 functions, which may have to be installed later:

In the IIS Metabase Explorer, the "OWA" entries must be deleted under "LM -> W3SVC -> 1 -> ROOT" and "LM -> W3SVC -> 2 -> ROOT":

Note: The entry under "LM -> W3SVC -> 1 -> ROOT" stands for the front end, "LM -> W3SVC -> 2 -> ROOT" is the OWA back end.

Both entries for OWA can be deleted in the IIS Metabase:

Now the OWA directory can be recreated with the Exchange Management Shell:

New-OWAVirtualDirectory -WebSiteName 'Default Web Site' -Server TEX1

And the back end can now also be created again:

New-OWAVirtualDirectory -WebSiteName 'Exchange Back End' -Server TEX1 -Role "Mailbox"

The OWA website is already loading again:

However, the URLs must be entered again:

In my case, this is "https://outlook.frankysweb.com/owa"

The remaining settings, for example for authentication, must also be adjusted according to your requirements:

As already mentioned at the beginning, it is also possible to reset the virtual directories via EAC. However, only the front end is ever recreated. If, as described here, errors occur in the back end, the Exchange Administrative Center will not help.

The remaining directories can also be recreated in the way described here (EWS, Active Sync). The procedure is the same and only the corresponding CMDLets need to be used for the other directories. One small exception, however, is the PowerShell directory. This will be dealt with in the next article.

Exit mobile version