posts - 0, comments - 1571, trackbacks - 0

Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

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 = 80

WebSite1 ( 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
 

 

Print | posted on Saturday, December 10, 2005 3:50 AM |

Feedback

Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

test
12/22/2005 12:01 PM | chris crowe
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Chris, thanks for this, it's the closest thing to what I've been looking for! I do have one question for you, is there any way to make this web-based? I need a way to list (and create links) for each internal site on our development site and wondered if this could be transformed somehow to do so?

Thanks in advance for any help, either way, with this!

Sincerely,
Jon
10/16/2007 12:30 AM | Jon Humphrey
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Chris,

This is awesome, you saved me days of work. Is it possible to see the IP addresses of FTP sites as well?

Thanks
9/2/2008 7:06 AM | James
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

For FTP Sites you just need to change the W3SVC to MSFTPSVC

Note: For IIS 7 (Vista + 2008 Server) it is even easier with more ways to do this:

* AppCMD
* WMI
* Microsoft.Web.Administration from C#, Powershell etc...
9/3/2008 7:29 AM | Chris
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Hi Chris...
Is there a way to do it on Apache?
6/26/2010 5:15 PM | Luciano
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Instead of all this run below command in command prompt

IISweb /query /Servername >>C:\\IIS_sites.txt

Lets be smart ;-)
7/1/2010 2:28 PM | Jagger
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

This is a great scrip, you saved my day, but now i would know if is possible to use this script to get this information on a list of servers.

Thanks.
7/20/2010 5:09 PM | Josue Fernando
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Any idea where the currently allowed IP addresses are stored in IIS v6?
8/6/2010 6:00 AM | kam
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Hi I am wondering how can I use this to list all the sites under 1 app.

Exemple in the IIS i have www.optilog.com and under that i have a lot of sites (www.optilog.com/mysite1, www.optilog.com/mysite2, etc) it's those under it that I need to list.

Any ideas? Thanks!
10/6/2010 4:01 AM | David
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

Included in the full install is a SSL Frequently Asked Questions that can assist in the learning of SSL for administrators
4/6/2012 5:50 PM | Jumper JK01-TT
Gravatar

# re: Display a list of all sites on the local IIS server and the bindings (IP Address, TCP/IP Port, Host Header) that they have.

From memory it should just work without a restart of IIS or the Server.
4/6/2012 6:09 PM | OEM U9GT 2

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 4 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET