New-OwaVirtualDirectory – An error occurred while creating the IIS virtual directory

During a recent update to Exchange 2016 CU9, I encountered the following error whilst trying to recreate one of the secondary OWA sites that I have running.

The command being executed was:

The error I was getting:

The usual suspect is that the object was not cleanly removed from the domain, so remove the object using ADSI, wait for replication and then carry on. In this case though, the object did not exist in the domain, not was there any trace of the site when browsing the IIS Admin Console.

The hint for me, was when checking the error in the Event Log, under Applications and Services Logs –> Microsoft –> Exchange. The error entry showed one more key bit of information – the error code was 0x800700B7 – which translates to ‘Cannot create a file when that file already exists’.

With this information, it told me that the cmdlet could not create the IIS virtual directory as it already exists. Sure enough, checking the IIS applicationHost.config file, the site still existed.

So, in my case, the fix was:

  1. Run notepad as administrator
  2. Open ‘C:\Windows\System32\inetsrv\config\applicationHost.config’
  3. Search for the site in the error, in my case ‘W3SVC/3/ROOT/owa’
  4. Comment out the section. In my case I commented out:
  5. Save the file
  6. Restart IIS
  7. Attempt to create the directory again
Be the first to like.

3 thoughts on “New-OwaVirtualDirectory – An error occurred while creating the IIS virtual directory

  1. I am bashing my freakin face in trying to figure this out. I am getting the same error when i try to create the OWA in a specific website. My IIS server has 3 web sites on it, only one is available publically. So i can create OWA on default web site and a TestOWA website i created with no problems. When i try to deploy it to the Team Foundation Server website, it fails with the error above. I have tried to go through the exchange logs like you mentioned however i have quite a few subdirectories under exchange and a multitude of different log files under there as well. Digging through them, i cant see anything related to or even time stamped near where this error is occuring. I have went in and commented out the data like you did in your file and that doesnt seem to make a different either.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.