Submitted By: Paul D.S. DiGiorgio

Enumerates all the Web sites on the specified server.

Visual Basic
Edit|Remove
' ***************************************************************** '
' IIS_WWW_Enum.vbs
'  by Paul DiGiorgio, 5-25-06
'   < pdsd@yahoo.com >
'   Enumerates all the IIS WWW sites in the given computer's metabase.
' ***************************************************************** '
Option Explicit
On Error Resume Next

Dim StartTime,EndTime: StartTime = Now ' For seeing how long the script takes to run
Wscript.Echo "StartTime = " & StartTime
' ***************************************************************** '
Dim objParent, strSite, ComputerName, strOutput
ComputerName = "WHITWEB1"
Set objParent = GetObject("IIS://" & ComputerName & "/W3SVC")
    If err.number <> 0 Then
        Wscript.Echo "Error enumerating sites on: " & ComputerName & " - " & err.number & " - " & err.description
    Else
        Wscript.Echo "Enumerating sites on: " & ComputerName
    End If
For Each strSite in objParent
    If IsNumeric(strSite.Name) Then
        strOutput = strSite.Name & " - " & strSite.ServerComment
        Wscript.Echo strOutput
    End If
Next
' ***************************************************************** '
EndTime = Now
Wscript.Echo vbCrLf & "EndTime = " & EndTime
Wscript.Echo "Seconds Elapsed: " & DateDiff("s", StartTime, EndTime)
Wscript.Echo "Script Complete"
Wscript.Quit(0)