Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 842
  • Last Modified:

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
0
introlux
Asked:
introlux
  • 5
1 Solution
 
introluxAuthor Commented:
Note all I need is the host header in alphabetical order
0
 
introluxAuthor Commented:
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

0
 
Chris DentPowerShell DeveloperCommented:

It's been a while since I used this one... But it returns all domains used in all host headers in IIS and writes them to a file.

It does not sort them into alphabetical order, is it really necessary for the script to do that? Or will you be using it in something like Excel which makes the task quite trivial?

Chris
' ListDomains
'
' Just a quick script to list the domains in use in IIS
'
' Author: Chris Dent
' Created: 04/05/2005
' Modified: 07/06/2005
 
' Runs for the local server by default
 
strServer = "localhost"
 
' Filename you want stuff to go into
 
strFileName = "c:\temp\DomainList.txt"
 
' Setup the output file
 
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.CreateTextFile(strFileName, True, False)
 
' Connect to the Web Service
 
Set objWebService = GetObject("IIS://" & strServer & "/W3SVC")
 
For Each objWebServer in objWebService
  If objWebServer.Class = "IIsWebServer" Then
    arrBindings = objWebServer.Get("ServerBindings")
    For Each strBinding in arrBindings
      arrTemp = Split(strBinding, ":")
      objFile.WriteLine arrTemp(UBound(arrTemp))
    Next
  End If
Next
 
objFile.Close
Set objFileSystem = Nothing
Set objWebService = Nothing

Open in new window

0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
introluxAuthor Commented:
forget alphabetical order. will do it in excel
i have run this but does not do anything
0
 
introluxAuthor Commented:
sorry it works!

thanks
0
 
introluxAuthor Commented:
top answer
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now