Display a list of all sites within IIS server

Display a list of all sites within IIS server

This script will show you each Web Site ID and the description and the bindings that they are using.

Save the script to a file with a .VBS file extension and then run using this command:

cscript  MyFile.VBS

MachineName = “localhost”
IIsObjectPath = “IIS://” & MachineName & “/w3svc”

Set IIsObject = GetObject(IIsObjectPath)
for each obj in IISObject
if (Obj.Class = “IIsWebServer”) then
BindingPath = IIsObjectPath & “/” & Obj.Name

Set IIsObjectIP = GetObject(BindingPath)
wScript.Echo IISObjectIP.ServerComment & ” ( W3SVC” & obj.Name & ” ) ”

ValueList = IISObjectIP.Get(“ServerBindings”)
ValueString = “”
For ValueIndex = 0 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)

if (HostHeader <> “”) then
wScript.Echo ” IP = ” & IP & ” TCP/IP Port = ” & TCP & “, HostHeader = ” & HostHeader
else
wScript.Echo ” IP = ” & IP & ” TCP/IP Port = ” & TCP
end if
Next
wScript.Echo “”
set IISObjectIP = Nothing
end if
next
set IISObject = Nothing

Example Output

Default Web Site ( W3SVC1 )
IP = 10.1.1.11 TCP/IP Port = 80WebSite1 ( W3SVC1036328378 )
IP = 10.1.1.74 TCP/IP Port = 80

WebSite2 ( W3SVC1816184000 )
IP = 10.1.1.73 TCP/IP Port = 80

WebSite3 ( W3SVC1867813904 )
IP = 10.1.1.72 TCP/IP Port = 80

WebSite4 ( W3SVC568530179 )
IP = 10.1.1.71 TCP/IP Port = 80

WebSite5 ( W3SVC719499532 )
IP = 10.1.1.70 TCP/IP Port = 80

WebSite6 ( W3SVC669732006 )
IP = (All Unassigned) TCP/IP Port = 81
 

Leave a Reply

Your email address will not be published.

one × four =

This site uses Akismet to reduce spam. Learn how your comment data is processed.