Friday, January 13, 2012

Extract bindings from IIS 6 metabase (the easy way)

Xslt can be very handy, specially when you have a bunch of data in xml format and you want to extract some.
To extract all the bindings froma running iis6 server the easiest way is to:

1) Create the XSL file
Save this XSLT file as metabase.xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:out="urn:microsoft-catalog:XML_Metabase_V64_0">
<xsl:output method="html" />
    <xsl:template match="/">
        <html>
        <body>
            <table border="1">
            <xsl:for-each select="//out:IIsWebServer">
                <tr>
                <td><xsl:value-of select="@ServerComment" /></td>
                <td><xsl:value-of select="@ServerBindings" /></td>
                </tr>
            </xsl:for-each>
            </table>
        </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
2) Tell metabase to use the XSL
Copy the metabase in a safe place (do not edit it in place) in the same folder where you saved metabase.xsl
Metabase usually sits on folder: C:\Windows\System32\Inetsrv
Edit the second line and add this:
<?xml-stylesheet type="text/xsl" href="metabase.xsl"?>

3) Open metabase.xml with you browser
Opening metabase now will show you all bindings in a nice table.


You may copy/paste in excel if you like.

Submit this story to DotNetKicks