Slee
Slee

Reputation: 28248

See which sites are using which IPs in IIS 7

Is there a way to quickly list which sites are on which IP address in IIS 7?

If I remember correctly you could sort a view of domains by IP in IIS 6 which was a big help to me in seeing which IPs I had available.

Upvotes: 11

Views: 2618

Answers (2)

John Lemp
John Lemp

Reputation: 5067

Take a look at APPCMD .

For example, to list all sites on the machine, use this command-line:

   %systemroot%\system32\inetsrv\APPCMD list sites

Upvotes: 7

Kieron
Kieron

Reputation: 27107

You can try this script:

MachineName = "localhost"
IIsObjectPath = "IIS://" & MachineName & "/w3svc"

WScript.Echo "Checking : " & IISObjectPath

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

        Set IIsObjectIP = GetObject(BindingPath)
        wScript.Echo BindingPath & " - " & IISObjectIP.ServerComment

        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

(source www.iisfaq.com)

Upvotes: 3

Related Questions