Login :: Register
General Topics
HostedbyMaximumASP170x35
2005 IIS MVPs
Other IIS Sites
  This script will export relevant IIS settings to a log file that you can import into MSAccess or MS Excel. 

This script will export relevant IIS settings to a log file that you can import into MSAccess or MS Excel.

The following script was sent to me by Herve Bour Schmitt Bour and it will export relevant settings from the IIS Metabase for all web sites to a text file that is either TAB or Comma seperated. You can then import this file into MS Access or MS Excel and do further reporting on it.

The fields that are exported are:

  • Web Site Instance ID
  • Web Site Description
  • IP Address
  • Host Header or TCP port
  • Web Site Protection Level (Low, Medium or High)
  • The status of the site (Stopped, Started)
  • Web Site Home Directory
  • Log file path
  • Log file type

Usage:

XportDb.VBS [--computer|-c COMPUTER]
                       [--file|-f ExportFileName]
                       [TAB or COMMA]
                       [--help|-?]

You can optionally specify the computer to interrogate
You can optionally specify the separator between the data either TAB or COMMA, the default is to export using a TAB
You can optionally specify the export filename - if none specified then the log is written to XportDb.TXT in the current directory

Example:

The following will export from the local computer all web sites using a TAB separator and will write the file to c:\logfiles\xportdb.vbs

cscript XportDB.VBS -c LocalHost TAB -f c:\logfiles\xportdb.vbs

Below is an example of the output from the export log file: c:\logfiles\xportdb.vbs

1,Default Web Site,(All Unassigned),80,Medium,stopped,j:\inetpub\wwwroot,%WinDir%\System32\LogFiles,1
2,Administration Web Site,(All Unassigned),2076,Medium,started,J:\WINNT\System32\inetsrv\iisadmin,%WinDir%\System32\LogFiles,1
3,Admin,(All Unassigned),81,Medium,started,c:\inetpub\websites\admin,%WinDir%\System32\LogFiles,1
4,IISFAQ,(All Unassigned),81,Medium,started,C:\Inetpub\websites\iisfaq.com,%WinDir%\System32\LogFiles,1
4,IISFAQ,(All Unassigned),8080,Medium,started,C:\Inetpub\websites\iisfaq.com,%WinDir%\System32\LogFiles,1
5,Thai Food,(All Unassigned),80,Medium,started,c:\inetpub\websites\thai,%WinDir%\System32\LogFiles,1

 

' This script will Check most parameters upon your W3SVC application '
' For more scripts go to www.iisfaq.com
'
' Herve Bour Schmitt Bour 12/02/2002
option Explicit
Dim ExportFilename, ArgComputerName, IISObjectPath, IISObject, FSO, TextFile, IIS4, Obj Dim BindingPath, IISObjectIP, ValueList, ValueString, ValueIndex, Value, Values, IP Dim TCP, HostHeader, Line, IISOBJRoot, separator
Function IsAppIsolatedABoolean Dim IIsSchemaPath, IIsSchemaObject ' Get the Schema of the property and determine if it's multivalued IIsSchemaPath = "IIS://localhost/Schema/AppIsolated" Set IIsSchemaObject = GetObject(IIsSchemaPath) IsAppIsolatedABoolean = (UCase(IIsSchemaObject.Syntax) = "BOOLEAN") Set IIsSchemaObject = nothing end function
' This function will return the site details or "" if it does not meed the application protection requirements 
function ReturnSiteProtectionIIS5(Site) 
Dim Protection, SiteRoot
ReturnSiteProtectionIIS5 = ""
Set SiteRoot = getObject("IIS://Localhost/W3svc/" & Site.Name & "/Root") 
if (Siteroot.AppIsolated = 1) then
    Protection = "High"
elseif (Siteroot.AppIsolated = 2) then
    Protection = "Medium"
else
    Protection = "Low"
end if
ReturnSiteProtectionIIS5 = Protection
Set SiteRoot = nothing
end function
' This function will return the site details or "" if it does not meed the application protection requirements 
function ReturnSiteProtectionIIS4(Site) 
Dim Protection, SiteRoot
ReturnSiteProtectionIIS4 = ""
Set SiteRoot = getObject("IIS://Localhost/W3svc/" & Site.Name & "/Root") 
if (Siteroot.AppIsolated = true) then
    Protection = "High"
else    
    Protection = "Low"
end if
ReturnSiteProtectionIIS4 = Protection
Set SiteRoot = nothing
end function
Function ReturnSiteProtectionIIS(Site)
  if (IIS4 = true) then
    ReturnSiteProtectionIIS = ReturnSiteProtectionIIS4(Site)
  else
    ReturnSiteProtectionIIS = ReturnSiteProtectionIIS5(Site)
  end if
end function
' Initialize some variables to determine what to show
IIS4 = IsAppIsolatedABoolean()
Function ReturnServerStatus(StatusValue)
   select case StatusValue
      case 1 
          ReturnServerStatus = "starting"
      case 2
          ReturnServerStatus="started"
      case 3
          ReturnServerStatus="stopping"
      case 4
          ReturnServerStatus="stopped"
      case 5
          ReturnServerStatus="pausing"
      case 6
          ReturnServerStatus="paused"
      case 7
         ReturnServerStatus="continuing"
     case else
         ReturnServerStatus = "Unknown status : " & StatusValue
  end select
end Function
Function ReturnPath(WebSitePath)
    Set IISOBJRoot = getObject(WebSitePath & "/Root")
    ReturnPath = IISOBJRoot.Path
    set IISOBJRoot = Nothing
end function
Function Returnlog(WebSitePath)
    Dim statut
    Set IISOBJRoot = getObject(webSitePath)
    Returnlog = IISOBJRoot.LogFileDirectory
    set IISOBJRoot = Nothing
end Function
Sub DisplayUsage()
 WScript.Echo "XportDb.VBS  [--computer|-c COMPUTER]"
 WScript.Echo "             [--file|-f ExportFileName]"
 WScript.Echo "             [TAB or COMMA]"
 WScript.Echo "             [--help|-?]"
 WScript.Echo ""
 WScript.Echo ""
 WScript.Echo "You can optionally specify the computer to get the interrogate"
 WScript.Echo "You can optionally specify the separator between the data either TAB or COMMA"
 WScript.Echo "You can optionally specify the export filename - if none specified then the"
 WScript.Echo "log is written to XportDb.TXT in the current directory"
 WScript.Echo ""
 WScript.Echo "Example 1   XportDB.VBS"
 WScript.Echo "Example 2   XportDB.VBS -c LocalHost TAB -f c:\logfiles\xportdb.vbs"
 WScript.Quit
End Sub
function CheckCommandLine
Dim oArgs, ArgNum
Set oArgs = WScript.Arguments
ArgNum = 0
While ArgNum < oArgs.Count
 Select Case LCase(oArgs(ArgNum))
  Case "--computer","-c":
   ArgNum = ArgNum + 1
   If (ArgNum >= oArgs.Count) Then
    Call DisplayUsage
   End If 
   ArgComputer = oArgs(ArgNum)
  Case "--file","-f":
   ArgNum = ArgNum + 1
   If (ArgNum >= oArgs.Count) Then
    Call DisplayUsage
   End If 
   ExportFilename = oArgs(ArgNum)
  case "tab" 
      separator = vbTab
  case "comma"
   separator = ","
  Case "--helpseparator-?"
   Call DisplayUsage
   CheckCommandLine = false
   exit function
  Case Else:
   Call DisplayUsage
   CheckCommandLine = false
   exit function
 End Select 
 ArgNum = ArgNum + 1
Wend
CheckCommandLine = true
end function
Exportfilename = "xportdb.txt"
ArgComputerName = "localhost"
IIsObjectPath = "IIS://" & ArgComputerName & "/w3svc"
separator = vbTab
if (CheckCommandLine = true) then
 Set IIsObject = GetObject(IIsObjectPath)
 Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
 Set TextFile = fso.CreateTextFile(ExportFileName, true) ' overwrite if exists

 for each obj in IISObject
   if (Obj.Class = "IIsWebServer") then
   BindingPath = IIsObjectPath & "/" & Obj.Name
   Set IIsObjectIP = GetObject(BindingPath)
   ValueList = IISObjectIP.Get("ServerBindings")
   ValueString = ""
   For ValueIndex = lbound(ValueList) To UBound(ValueList)
     value = ValueList(ValueIndex)
     Values = split(value, ":")
     IP = values(0)
     if (IP = "") then
     IP = "(All Unassigned)"
     end if  
     TCP = values(1)
     if (TCP = "") then
    TCP = "80"
     end if  
     HostHeader = values(2)
     Line = ""
     Line = Line & Obj.Name & separator &IISObjectIP.ServerComment & separator & IP & separator
     if (HostHeader <> "") then
    Line = Line & HostHeader & separator
     else
    Line = Line & TCP & separator 
     end if
     Line = line & ReturnSiteProtectionIIS(IIsObjectIP) & separator & ReturnServerStatus(IISObjectIP.Status)
     Line = Line & separator & Returnpath(IISObjectIP.ADSPath) & separator & Returnlog(IISObjectIP.ADSPath) 
     Line = Line & separator & IISObjectIP.LogType
     Textfile.Writeline Line
  Next
  set IISObjectIP = Nothing
  end if
   next
 set IISObject = Nothing
 textfile.Close
 Set textFile =Nothing
 Set FSO = Nothing
 WScript.echo "Web site details have been exported to : " & ExportFilename
end if
 This site and its contents are Copyright 1999-2004 by IISFAQ Microsoft Corporation in no way endorses or is affiliated with IISFAQ