Search for host headers in IIS

I had an issue today that required me to determine what virtual directory was responding to a particular host header. I quickly located a VB script that handled this task with ease. The script is courtesy of this page: http://serverfault.com/questions/107619/how-do-i-get-a-list-of-websites-from-iis-showing-the-host-header-value-descript

OPTION EXPLICIT

DIM CRLF, TAB
DIM strServer
DIM objWebService

TAB  = CHR(9)
CRLF = CHR(13)& CHR(10)IF WScript.Arguments.Length =1THEN
    strServer = WScript.Arguments(0)ELSE
    strServer ="localhost"ENDIF

WScript.Echo "Enumerating websites on "& strServer & CRLF
SET objWebService = GetObject("IIS://"& strServer &"/W3SVC")
EnumWebsites objWebService


SUB EnumWebsites( objWebService )DIM objWebServer, objWebServerRoot, strBindings

    FOREACH objWebServer IN objWebService
        IF objWebserver.Class="IIsWebServer"THENSET objWebServerRoot = GetObject(objWebServer.adspath &"/root")
            WScript.Echo _
                "Site ID = "& objWebserver.Name & CRLF & _
                "Comment = """& objWebServer.ServerComment &""" "& CRLF & _
                "State   = "& State2Desc( objWebserver.ServerState )& CRLF & _
                "Path   = "& objWebServerRoot.path & CRLF & _
                "LogDir  = "& objWebServer.LogFileDirectory & _
                ""' Enumerate the HTTP bindings (ServerBindings) and' SSL bindings (SecureBindings)
            strBindings = EnumBindings( objWebServer.ServerBindings )& _
                          EnumBindings( objWebServer.SecureBindings )IFNOT strBindings =""THEN
                WScript.Echo "IP Address"& TAB & _
                             "Port"& TAB & _
                             "Host"& CRLF & _
                             strBindings
            ENDIFENDIFNEXTENDSUBFUNCTION EnumBindings( objBindingList )DIM i, strIP, strPort, strHost
    DIM reBinding, reMatch, reMatches
    SET reBinding =NEW RegExp
    reBinding.Pattern ="([^:]*):([^:]*):(.*)"FOR i = LBOUND( objBindingList )TO UBOUND( objBindingList )' objBindingList( i ) is a string looking like IP:Port:HostSET reMatches = reBinding.Execute( objBindingList( i ))FOREACH reMatch IN reMatches
            strIP = reMatch.SubMatches(0)
            strPort = reMatch.SubMatches(1)
            strHost = reMatch.SubMatches(2)' Do some pretty processingIF strIP =""THEN strIP ="All Unassigned"IF strHost =""THEN strHost ="*"IF LEN( strIP )<8THEN strIP = strIP & TAB

            EnumBindings = EnumBindings & _
                           strIP & TAB & _
                           strPort & TAB & _
                           strHost & TAB & _
                           ""NEXT

        EnumBindings = EnumBindings & CRLF
    NEXTENDFUNCTIONFUNCTION State2Desc( nState )SELECTCASE nState
    CASE1
        State2Desc ="Starting (MD_SERVER_STATE_STARTING)"CASE2
        State2Desc ="Started (MD_SERVER_STATE_STARTED)"CASE3
        State2Desc ="Stopping (MD_SERVER_STATE_STOPPING)"CASE4
        State2Desc ="Stopped (MD_SERVER_STATE_STOPPED)"CASE5
        State2Desc ="Pausing (MD_SERVER_STATE_PAUSING)"CASE6
        State2Desc ="Paused (MD_SERVER_STATE_PAUSED)"CASE7
        State2Desc ="Continuing (MD_SERVER_STATE_CONTINUING)"CASEELSE
        State2Desc ="Unknown state"ENDSELECTENDFUNCTION