Elencare i siti presenti in IIS
Questo script permette di ottenere l'elenco dei siti web creati su IIS con relativi hostHeader.
Per eseguire lo script dal prompt:
VBScript: IISList.wsf
<job>
<runtime>
<description>Elenco siti</description>
<named name="server" helpstring="Nome del server" required="true" />
<unnamed name="onlyHost" helpstring="visualizza solo gli hostHeader" many="false" required="false" />
</runtime>
<!-- ====== DA INCLUDERE IN OGNI SCRIPT ====== -->
<!-- Microsoft ActiveX Data Objects 2.6 Library -->
<reference guid="{00000206-0000-0010-8000-00AA006D2EA4}" version="2.6" />
<!-- Microsoft CDO for Windows 2000 Library -->
<reference guid="{CD000000-8B95-11D1-82DB-00C04FB1625D}" version="1.0" />
<!-- Microsoft XML, v4.0 -->
<!--reference guid="{F5078F18-C551-11D3-89B9-0000F81FE221}" version="4.0" /-->
<!-- ====== FINE ====== -->
<script language="VBScript" >
Option explicit
Dim strServer, objIIS, flagID, objWebSite, i, ServerBindings, Servervars, bolHost
if not WScript.Arguments.Named.Exists("server") then
WScript.Arguments.ShowUsage()
WScript.Quit -1
end if
bolHost = false
for i = 0 to WScript.Arguments.Unnamed.count -1
if lcase(WScript.Arguments.Unnamed.Item(0)) = "onlyhost" then
bolHost = true
end if
next
strServer = WScript.Arguments.Named.Item("server")
WScript.Echo "Server: " & strServer
i = 1
Set objIIS = getObject("IIS://" & strServer & "/w3svc")
for each objWebSite in objIIS
if (objWebSite.class = "IIsWebServer") then
if bolHost = false then
WScript.StdOut.WriteLine vbCrLf & i & ") " & objWebSite.ServerComment & " - ID: " & objWebSite.name
end if
ServerBindings = objWebSite.ServerBindings
for each Servervars in ServerBindings
WScript.StdOut.WriteLine " |" & Servervars & "|"
next
i = i + 1
end if
next
set objIIS = nothing
WScript.StdOut.WriteLine "Fine."
WScript.Quit 0
</script>
</job>
cscript IISList.wsf /server:127.0.0.1