Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In an effort to try and take the pointy-clickyness out of configuring IIS for our application, I've been looking at appcmd. Specifically it's ability to export config trees and reapply them with minimum fuss.

Generally, this gives the exported configuration:

appcmd list Config /section:httpProtocol /config /xml > template.xml

which I can then reimport at a later date with:

appcmd set Config /in < template.xml

and the changes get applied. This works well for everything other than custom error pages.

I've exported these with:

appcmd list Config "Default Web Site/intranet" /section:httpErrors /config /xml > customerrors.xml

but when I try and import with:

appcmd set Config /in < customerrors.xml

I get the following error:

ERROR ( hresult:8007000d, message:The input contained an error element, which may
indicate that the operation producing the input has failed.  )

Well yes, that's because I'm importing errohandler entries that look like this:

<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
  <CONFIG CONFIG.SECTION="system.webServer/httpErrors" path="MACHINE/WEBROOT/APPHOST/Default Web Site/intranet" overrideMode="Inherit"
locked="false">
    <system.webServer-httpErrors errorMode="Custom">
      <error statusCode="500" prefixLanguageFilePath="" path="/intranet/ErrorPages/500-100.asp" responseMode="ExecuteURL" />
      <error statusCode="500" subStatusCode="100" path="/intranet/ErrorPages/500-100.asp" responseMode="ExecuteURL" />
    </system.webServer-httpErrors>
  </CONFIG>
</appcmd>

...which is what appcmd gave me (which would imply that the 'error' element really is what is required). Is this a case of appcmd trying to be too clever, or am I missing something ridiculously obvious?

Cheers!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Funny. So the appcmd import seems to watch for the word 'error' as a real error, not accounting for this legit situation. I'll see if I can find out more information about that for you.

As for a solution in the meantime, with appcmd, the best way to find out the syntax is to use Configuration Editor. Make the change you want, then go to "Generate Script" on the right and click on the AppCmd tab. That's an excellent trick to get the syntax that you need.

Here's an example of how to do the httpErrors:

appcmd.exe set config "Default Web Site" -section:system.webServer/httpErrors /+"[statusCode='503',path='503.htm']"
share|improve this answer
    
Oo... didn't realise you could do that. Never explored it :-) Thanks for that tip. Makes dichpering appcmd a little bit easier...! –  Chris J Sep 2 '11 at 9:25
    
Yep that does the job and gives me a better insight into how to use appcmd as well. Be interested to know tohugh if you do find out why httpErrors can't be imported :-) Suspecting it's an oversight... –  Chris J Sep 2 '11 at 13:29
    
I agree, it seems like an oversight. I've asked on a forums with the IIS team. I'll post back when I find out. –  Scott Forsyth - MVP Sep 2 '11 at 14:49
1  
Hi Chris, I got confirmation that Microsoft has logged this as a bug, and they pass along their thanks for reporting it. –  Scott Forsyth - MVP Sep 2 '11 at 20:42
    
Excellent -- cheers Scott. –  Chris J Sep 8 '11 at 8:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.