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

5

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.

Toby answered 5/9, 2012 at 9:57 Comment(1)
For those of us who likes the GUI utils - The IIS manager - Advanced settings - IDAccommodative
T
31

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)
Toby answered 6/9, 2012 at 8:56 Comment(2)
You can get a specific property of the Site (id, bindings, state) by using the /text:{property} argument. For example, to get just the ID (returns simply "1"): APPCMD list site "Default Web Site" \text:idOutdoors
this worked for me on iis 6, with the only exception being that I had to run the command prompt as an administratorIntercommunion
V
17

The easiest way is to load up IIS Manager and click on the "Sites" folder. There should be a column called "ID" in the list shown in the Features View pane, and that's your Site ID.

Verecund answered 6/10, 2016 at 13:10 Comment(1)
Dave - This is certainly the easiest and instant display of the site ID right in front of us when the "Sites" main folder is clicked :) Excellent.Superintendent
N
5

You may also give a try to Powershell get-website commandlet. Without args it will list all sites together with IDs.

Neanderthal answered 31/3, 2015 at 14:50 Comment(0)
B
2

Here is the Powershell-way of doing it:

Get-Website -Name "Default Web Site" | Select -ExpandProperty ID

(Replace Default Web Site with your site's name.)

Buncombe answered 21/2, 2019 at 10:42 Comment(0)
D
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
Desilva answered 5/9, 2012 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.