Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"?>
  <CONFIG CONFIG.SECTION="system.webServer/httpErrors" path="MACHINE/WEBROOT/APPHOST/Default Web Site/intranet" overrideMode="Inherit"
    <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" />

...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?


share|improve this question
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
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

Your Answer


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.