Link to home
Start Free TrialLog in
Avatar of introlux
introluxFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Method to export all site headers

Hi Experts,

I would like to know if there is a method to copy all site headers to a csv file. Rather than copy and paste each host header one by one.

Any suggestions how this can be done? I am using windows server 2003.

Regards,

introlux
Avatar of introlux
introlux
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Note all I need is the host header in alphabetical order
I have at the moment to script below in VB that produces too much info. I only need the host header and preferably in alphabetical order.

Regards,

introlux
' Enumerate IIS Configuration for Auditing
 
OPTION EXPLICIT
 
DIM strServer, strServerType, strServerMetaType, objFile, strGuyFile, strFilePath
DIM objService
 
strServer = "localhost"
strServerType = "Web"
strServerMetaType = "W3SVC"
 
 
strFilePath = "C:\IISAudit.csv"
Set objFile = CreateObject("Scripting.FileSystemObject")
Set strGuyFile = objFile.CreateTextFile(strFilePath, True)
 
strGuyFile.WriteLine("ID,IP Address,Port,Host Header")
 
IF WScript.Arguments.Length >= 1 THEN
    strServer = WScript.Arguments( 0 )
END IF
 
IF WScript.Arguments.Length = 2 THEN
    strServerType = WScript.Arguments( 1 )
 
    IF UCASE( strServerType ) = "FTP" THEN
        strServerType = "Ftp"
        strServerMetaType = "MSFTPSVC"
    ELSE
        strServerType = "Web"
        strServerMetaType = "W3SVC"
    END IF
END IF
 
SET objService = GetObject( "IIS://" & strServer & "/" & strServerMetaType )
EnumServersites objService
 
 
SUB EnumServersites( objService )
    DIM objServer, strBindings
 
    FOR EACH objServer IN objService
        IF objServer.Class = "IIs" & strServerType & "Server" THEN
            strGuyFile.WriteLine( _
                objServer.Name & _
		strBindings)
		
 
            ' Enumerate the HTTP bindings (ServerBindings) and
            ' SSL bindings (SecureBindings) for HTTPS only
            strBindings = EnumBindings( objServer.ServerBindings )
 
            'IF strServerType = "Web" THEN
            '    strBindings = strBindings & _
            '    EnumBindings( objServer.SecureBindings )
            'END IF
 
            'IF NOT strBindings = "" THEN
            '    WScript.Echo strBindings
            'END IF
        END IF
    NEXT
 
END SUB
 
FUNCTION 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:Host
        SET reMatches = reBinding.Execute( objBindingList( i ) )
        FOR EACH reMatch in reMatches
            strIP = reMatch.SubMatches( 0 )
            strPort = reMatch.SubMatches( 1 )
            strHost = reMatch.SubMatches( 2 )
 
            ' Do some pretty processing
            IF strIP = "" THEN strIP = "All Unassigned"
            IF strHost = "" THEN strHost = "*"
            'IF LEN( strIP ) < 8 THEN strIP = strIP & VbTab
 
            EnumBindings = EnumBindings & "," & _
                           strIP & "," & _
                           strPort & "," & _
                           strHost & ","
        NEXT
 
        EnumBindings = EnumBindings & VbCrLf
    NEXT
 
END FUNCTION
 
FUNCTION State2Desc( nState )
    SELECT CASE nState
    CASE 1
        State2Desc = "Starting"
    CASE 2
        State2Desc = "Started"
    CASE 3
        State2Desc = "Stopping"
    CASE 4
        State2Desc = "Stopped"
    CASE 5
        State2Desc = "Pausing"
    CASE 6
        State2Desc = "Paused"
    CASE 7
        State2Desc = "Continuing"
    CASE ELSE
        State2Desc = "Unknown"
    END SELECT
 
END FUNCTION

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
forget alphabetical order. will do it in excel
i have run this but does not do anything
sorry it works!

thanks
top answer