如何使用appcmd或其他工具在Windows 2008上使用站点名称查找IIS7 SiteID?

问题描述 投票:16回答:5

我试图使用appcmd或其他实用程序使用站点名称找到IIS7站点ID,但没有找到任何方法来实现它。

iis-7 appcmd
5个回答
23
投票

以下命令返回站点ID:

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

示例输出:

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)

9
投票

最简单的方法是加载IIS管理器并单击“站点”文件夹。在“功能视图”窗格中显示的列表中应该有一个名为“ID”的列,这是您的站点ID。


5
投票

您也可以试试Powershell get-website命令行开关。如果没有args,它将列出所有网站和ID。


1
投票

保存为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

然后从命令行

XXX.vbs site.tofind.com

要么

cscript XXX.vbs site.tofind.com

1
投票

以下是Powershell的做法:

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

(将默认网站替换为您的网站名称。)

© www.soinside.com 2019 - 2024. All rights reserved.