How to delete a URL rewrite rule in IIS7 from the command prompt if it’s got spaces in the name

appcmdiis-7rewrite

The appcmd help is a little vague and I can't seem to figure out the proper escape or quoting sequence.

appcmd set config
-section:defaultDocument /-files.[value='main.html']

Remove a collection element with
the specified keys in the
collection of the
"system.webServer/defaultDocument"
configuration section.

This works fine:

appcmd set config -section:system.webServer/rewrite/globalRules /-[name='rulename']

This does not:

appcmd set config -section:system.webServer/rewrite/globalRules /-[name='rule name']

The rule in question has multiple spaces and a forward slash (/) in the name.

Best Answer

You should be able to delete using a combination of double and single quotes like:

appcmd.exe set config -section:system.webServer/rewrite/globalRules /-"[name='test rule with / in name']"

Try using Configuration Editor, it will generate the AppCmd.exe command automatically, it is included in IIS 7.5 and you can download it for IIS 7.0 at http://www.iis.net/download/AdministrationPack