Alex Rivera | Logout

How to find IIS7 SiteID using site name on Windows 2008 using appcmd or other util?

Asked 2012-09-05T09:57:35.370
25

I am trying to find an IIS7 site ID using site name using appcmd or other utility but have not found any way to achieve it.

Edit
Report

2 Answers

32

The following command returns site ID:

%systemroot%\system32\inetsrv\APPCMD list site <SiteName>

Example output:

SITE "Default Web Site" (id:1,bindings:http/*:80:default.local,state:Started)
SITE "My Site" (id:2,bindings:http/*:80:my.local,state:Started)
answered 2012-09-06T08:56:48.730
1

Save this a XXX.VBS

dim lookfor: lookfor = lcase(WScript.Arguments(0))
dim ws: set ws = getobject("IIS://localhost/w3svc")
for each site in ws
    if site.class = "IIsWebServer" then
        if lcase(site.ServerComment) = lookfor then
            wscript.echo "id=" & site.Name & ", name=" & site.ServerComment
        end if
    end if
next

then from the command line

XXX.vbs site.tofind.com

or

cscript XXX.vbs site.tofind.com
answered 2012-09-05T10:31:37.850

Your Answer