locked
Using Powershell how to Revert-to-Parent in handler mappings for an application in IIS RRS feed

  • Question

  • User1611411552 posted

    I want to modify the IIS Web application Handler mappings to Revert to Parent. I did this manually like below.

    Open IIS , Site/Web application, Clicked Handler Mappings, in Actions Clicked "Revert to Parent".

    I want to automate this using PowerShell. Can someone help?

    I have already tried below :-

    1) Clear-WebConfiguration -pspath 'IIS:/sites/Default Web Site/MyWebService' -filter 'system.webServer/handlers'

    2) Clear-WebConfiguration -Filter /System.WebServer/Handlers -PSPath 'IIS:/sites/Default Web Site/MyWebService' -force

    3) Set-WebConfiguration -Filter /System.WebServer/Handlers -Value @{Name='CGI-exe'; EntryType='Inherited'; AccessPolicy="Read, Script"} -PSPath "IIS:/sites/Default Web Site/MyWebService"

    4) Set-WebConfiguration "/system.webServer/handlers/@AccessPolicy/add[@name='CGI-exe']" -Value "Read, Script" -PSPath "IIS:/sites/Default Web Site/MyWebService"

    Set-WebConfiguration "/system.webServer/handlers/add[@name='CGI-exe']/@requireAccess" -Value "Execute" -PSPath "IIS:/sites/Default Web Site/MyWebService"

    But none suffices my need to "Revert to Parent"

    Thursday, July 28, 2016 7:40 PM

All replies

  • User1278090636 posted

    Hi,

    When you clikc Revert to Parent, it will delete all the handler settings from the web.config.

    So you can use the following powershell script to clear the handler settings from the web.config. Which works the same as Revert to Parent.

    Set-Location IIS:\sites\$Site
    clear-WebConfiguration -filter /system.webserver/handlers -force

    Best Regards,

    Jean

    Friday, July 29, 2016 2:41 AM
  • User1611411552 posted

    This removes all the handler mapping but not the Msi-Custom* mappings.

    I actually don't want to remove all mapping just revert-to-parent. This should actually just remove all the custom mappings and disable CGI-exe and ISAPI-dll.

    Friday, July 29, 2016 8:52 AM
  • User1278090636 posted

    Hi,

    I'm wondering about how you configure the custom mappings.

    Could you please post related configure settings in the web.config to here?

    Best Regards,

    Jean

    Monday, August 1, 2016 7:14 AM
  • User1611411552 posted

    I just see these custom mappings that starts with "Msi-Custom" whenever I host a new application in IIS.

    I have not explicitly added these to web.config. Following is an example of my web.confg:-

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <system.diagnostics>
        <trace useGlobalLock="false" />
      </system.diagnostics>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" enableVersionHeader="false" />
      </system.web>
      <system.webServer>
        <httpProtocol>
          <customHeaders>
            <remove name="X-Powered-By" />
          </customHeaders>
        </httpProtocol>
      </system.webServer>
      <system.net>
        <connectionManagement>
          <add address="*" maxconnection="100" />
        </connectionManagement>
      </system.net>
      <system.serviceModel>
        <!-- Used 2MB for received message size -->
        <bindings>
          <webHttpBinding>
            <binding name="MessageSize" maxReceivedMessageSize="2097152">
              <security mode="Transport">
                <transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
              </security>
            </binding>
          </webHttpBinding>
        </bindings>
        <services>
          <service name="MyServiceAPI">
            <endpoint address="https://localhost/MyService/MyService.svc" behaviorConfiguration="webHttpBehavior" 
    binding="webHttpBinding" bindingNamespace="urn:alogent-schema:MyService"
    bindingConfiguration="MessageSize" contract="IMyServiceAPI" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceDebug includeExceptionDetailInFaults="false" httpHelpPageEnabled="false" httpsHelpPageEnabled="false" /> <serviceMetadata httpsGetEnabled="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="webHttpBehavior"> <webHttp helpEnabled="false" defaultOutgoingResponseFormat="Json" /> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" /> </system.serviceModel> <connectionStrings> <add name="OperationalDbContext" providerName="System.Data.SqlClient" connectionString="" /> </connectionStrings> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> </entityFramework> </configuration>
    Wednesday, August 3, 2016 2:29 PM
  • User1278090636 posted

    Hi,

    It seems that you forget to add the image url.  I can't find any setting related to Msi-Custom in your configuration file and on my side.

    Best Regards,

    Jean

    Thursday, August 4, 2016 2:48 AM
  • User1611411552 posted

    Could this be because of some WIX settings?

    Thursday, August 4, 2016 11:42 AM
  • User1278090636 posted

    Hi,

    I'm not familiar with WIX.

    You can check if the web.config file is changed after you installed the WIX.

    Best Regards,

    Jean

    Monday, August 8, 2016 8:08 AM