1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
| ' 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
Dim ServerName
ServerName = "xxxx" '<-------------------- nom du serveur dont on veut lister les sites IIS
Function IsAppIsolatedABoolean
Dim IIsSchemaPath, IIsSchemaObject
' Get the Schema of the property and determine if it's multivalued
IIsSchemaPath = "IIS://" & ServerName & "/Schema/AppIsolated"
Set IIsSchemaObject = GetObject(IIsSchemaPath) ' <----------------------------- erreur sur cette ligne
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://" & ServerName & "/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://" & ServerName & "/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 "diese"
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"
ArgComputerName = ServerName
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 |
Partager