What is the Windows Server 2012 command line equivalent of `aspnet_regiis -ir`?


As documented in several questions (Alternative for the Registering ASP.NET 4.5 on Windows Server 2012; Server 2012 IIS 8 MVC app shows default IIS home page or 403 / 404 errors; WCF on IIS8; *.svc handler mapping doesn't work), on Windows Service 2012 the aspnet_regiis -ir command does not work anymore, and instead produces the following output:

This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.

In our case, we only want to run this command to re-register ASP.NET 4.5, since some other installation un-registered it: ASP.NET 4.5 is installed already.

Using the UI (Add/Remove roles/features), inspired by the referenced posts, I found that it suffices to remove WCF's HTTP Activation feature and then add it again. (But I needed to uninstall/reinstall a feature that happens to depend on WCF HTTP Activation...)

Question: How can this same thing be done through the command line on Windows Server 2012?

(I looked at this dism.exe thing, but it looks daunting, and dism.exe -? didn't help me at all.)

Thanks!


Answers:


Dism would be the best way to do this:

Dism /online /Disable-Feature /FeatureName:WCF-HTTP-Activation45
Dism /online /Enable-Feature /FeatureName:WCF-HTTP-Activation45

Use the /all switch when enabling to enable all parent features.