.

đź§©Recreating Exchange Virtual Directories: When Reset is the Fix

📌Basic information

After you install Exchange 2016+ Server you will have two web sites in IIS:

  • Default Web Site
  • Exchange Back End

Clients connect  to  Default Web Site via corresponding virtual directories (EWS, OAB, RPC, Autodiscover, etc.). Than, request is proxied to Mailbox server Exchange Back End Site:

These sites are relatively similar from its structure point of view. You may need to recreate IIS virtual directories responsible for different functions in Microsoft Exchange Server 2016 (for example, virtual directory was removed by accident).

Also, this scenario can be useful if users experience some issues with Outlook on the Web (OWA) or mobile services. If PowerShell virtual directory is corrupted, it will be impossible to run Exchange Management Shell.

You can use following cmdlets to verify properties of each virtual directory:

Get-Command Get-*VirtualDirectory | ft Name

Expected output:

Name

—-

Get-ActiveSyncVirtualDirectory

Get-AutodiscoverVirtualDirectory

Get-EcpVirtualDirectory

Get-OabVirtualDirectory

Get-OwaVirtualDirectory

Get-PowerShellVirtualDirectory

Get-WebServicesVirtualDirectory

Get-MapiVirtualDirectory

You can see the list of virtual directories which exist on the server and cmdlets to review properties for each corresponding directory. For example, for ActiveSync directory:

Get-ActiveSyncVirtualDirectory -Server EX16MBX1 | ft Identity

Successful output (server name, directory name and Web site for that directory):

Name

—-

EX16MBX1\Microsoft-Server-ActiveSync (Default Web Site)

The process is the same for other directories.

đź’ˇNote: You should use -ShowMailboxVirtualDirectories switch to review directories in Exchange Back End Site.

Usually, the process of recreation is straightforward. You need to remove and/or create directory and recovery specific settings (internal and external urls, authentication options and etc.)

However, some operations are specific for some directories, and I would highly recommend to describe that in your disaster recovery plan.   

🔄Offline Address Book

If server was responsible for OAB distribution and global web distribution was not enabled, you need to enable Client Access OAB virtual directory for OAB distribution again. For example, perform that operation for ’Default Offline Address Book’ OAB:

$CurrentOABVdirs = (Get-OfflineAddressBook ‘Default Offline Address Book’).VirtualDirectories $VDirToAdd = Get-OABVirtualDirectory ‘EX16MBX1\OAB (Default Web Site)’ $NewSetOfOABVdirs = $CurrentOABVdirs + $VDirToAdd Set-OfflineAddressBook ‘Default Offline Address Book’ -VirtualDirectories $NewSetOfOABVdirs

However, if your organization has Global Web Distribution enabled, you don’t need to correct the list of virtual directories. For more information about global web distribution, please, visit:

đź”—https://blogs.technet.microsoft.com/exchange/2014/10/29/oab-improvements-in-exchange-2013-cumulative-update-7/

To enable Global Web Distribution in your Exchange Organization:

Set-OfflineAddressBook ‘Default Offline Address Book’ -VirtualDirectories $null -GlobalWebDistributionEnabled $true

🔄PowerShell

The PowerShell virtual directory cannot be removed or created by using the Exchange Management Shell because you are currently using it. You need to run standard Windows PowerShell console and add the Microsoft Exchange Management Snap-in.

To run the following Windows PowerShell command, you need to install the In Exchange 2016 Management Tools.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

To create the Front-End virtual Directory:

New-PowershellVirtualDirectory –Name “Powershell” -RequireSSL $false -CertificateAuthentication $true -BasicAuthentication $false -InternalUrl http://EX16MBX1.contoso.net/PowerShell

To create the Back-End virtual Directory:

New-PowershellVirtualDirectory –Name “Powershell” -Role Mailbox -RequireSSL $true -CertificateAuthentication $true -WindowsAuthentication $true -Path “C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\PowerShell-Proxy”

Finally, you also need to verify that the settings of the virtual directory are correct, like don’t require SSL, folder permissions, etc. if applicable. Note, that PowerShell virtual directory for back end web site is created with incorrect PhysicalPath  –  to “C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\PowerShell”. If you recreate virtual directory with default settings, you will still not be able to run EMS (error is not really meaningful in that case):

You can compare settings for working and not-working servers:

The command above allows you to recreate PowerShell VD with correct settings.

End.


Leave a comment