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:
New-OwaVirtualDirectory -Server $ServerName -WebsiteName "EAC_Secondary" | Out-Null
The error I was getting:
An error occurred while creating the IIS virtual directory 'IIS://exch04.domain.local/W3SVC/3/ROOT/owa' on 'exch04'. + CategoryInfo : InvalidOperation: (exch04\owa (EAC_Secondary):ADObjectId) [New-OwaVirtualDirectory], InvalidOperationException + FullyQualifiedErrorId : [Server=exch04,RequestId=8d989c2d-4c79-4c5c-932d-5cc97804b721,TimeStamp=08/05/2018 14:09:13] [FailureCategory=Cmdlet-InvalidOperationException] 628F3B52,Microsoft.Exchange.Management.SystemConfigurationTasks.NewOwaVirtualDirectory + PSComputerName : exch04.domain.local
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:
- Run notepad as administrator
- Open ‘C:\Windows\System32\inetsrv\config\applicationHost.config’
- Search for the site in the error, in my case ‘W3SVC/3/ROOT/owa’
- Comment out the section. In my case I commented out:
<!--<key path="LM/W3SVC/3/ROOT/owa"> <property id="2102" dataType="String" userType="100" attributes="Inherit" value="owa" /> <property id="45054" dataType="DWord" userType="1" attributes="Inherit" value="1" /> </key> <key path="LM/W3SVC/3/ROOT/owa/auth"> <property id="1002" dataType="String" userType="1" attributes="None" value="IIsWebDirectory" /> </key>-->
- Save the file
- Restart IIS
- Attempt to create the directory again