How to remove a HTTP module using PowerShell in IIS

Published Mar 09 2022 03:08 PM 1,182 Views
Microsoft

There could be an instance where a dll that is specified in IIS that is not present. When this occurs, there are three possibilities. 

trevorchamblee_2-1646862773222.png

 

You may see an event similar to this when the first request hits the application pool.

 

1. You have migrated the settings from one server to another that does not have the module installed that is being called for. For example, the previous server had urlrewrite installed but the new one does not (most common).

 

2. There is a custom module that applicationhost.config is looking for that is not present.

 

3. An unwanted module has been added to IIS and application pool(s) cannot be started when the corresponding dll file is deleted.

 

When identified thru the event log you can see which module is causing the issue. For the purpose of the article, we are using Rewritemodule as an example.

 

MicrosoftTeams-image (1).png

 

If we want to remove this setting via PowerShell, you can do so with the following commands.

 

Remove-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/globalModules" -name "." -AtElement @{name='RewriteModule'}

Remove-WebConfigurationProperty  -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/modules" -name "." -AtElement @{name='RewriteModule'}

 

In combination with these two scripts and an IIS reset the app pools should now be able to start.

Co-Authors
Version history
Last update:
‎Mar 09 2022 03:16 PM
Updated by: