"Installation of one or more roles, role services, or features failed. Error: 0x800f0922" when installing IIS 8.0 Application Initialization.

The other day I got a case where customer was trying to install the Application Initialization feature on a Windows 2012 / IIS 8.0 machine. 

IIS 8.0 Application Initialization
https://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

However, this failed for customer. And it showed that it failed for me too.
When attempting to install it from the Server Manager, the error looked like this: 

 

When attempting to install it from a PowerShell command prompt, the error looked like this: 

Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

 

PS C:\Windows\system32> Import-Module ServerManager
PS C:\Windows\system32> Add-WindowsFeature Web-AppInit
Add-WindowsFeature : The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed. Error: 0x800f0922
At line:1 char:1
+ Add-WindowsFeature Web-AppInit
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature], Exception
    + FullyQualifiedErrorId : DISMAPI_Error__Failed_To_Enable_Updates,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
Success Restart Needed Exit Code Feature Result

------- -------------- --------- --------------
False No Failed {}

When researching on this, I didn’t find much (hence this post).
When investigating the IIS.log I noticed that there were some Accessed Denied (0x80070005)

 

[<date time>] [ ***** IIS 8.0 Component Based Setup ***** ]
[<date time>] "C:\Windows\System32\inetsrv\iissetup.exe" /launch C:\Windows\System32\inetsrv\appcmd.exe reset config -section:system.webServer/applicationInitialization
[<date time>] Launching command C:\Windows\System32\inetsrv\appcmd.exe, with params C:\Windows\System32\inetsrv\appcmd.exe reset config -section:system.webServer/applicationInitialization
[<date time>] < !!FAIL!! > LaunchCommand result=0x80070005
[<date time>] [ End of IIS 8.0 Component Based Setup ]

Some further testing showed that I (and customer) had Shared Configuration enabled on the machine.
And, in short, the installer runs with an identity that normally do not have access to the share where the shared configuration applicationhost.config is located.
And, equally short, the solution here was to disable Shared Configuration during the installation of the Application Initialization feature.

So if you see the error above when installing the Application Initialization feature then check if Shared Configuration is enabled.
If yes, disable Shared Configuration, perform an IISReset, run the “Add-WindowsFeature Web-AppInit” command from PowerShell (or install it from the Server Manager).

 

Hope this helps.

Installing IIS Modules in Shared Configuration Environments
https://www.iis.net/learn/manage/provisioning-and-managing-iis/installing-iis-modules-in-shared-configuration-environments