iis-7 - Powershell Get-WebSite名称参数被忽略

标签 iis-7 windows-7 powershell

我想使用PowerShell Get-Website cmdlet检索有关特定IIS 7网站的信息。不幸的是,无论我传入的-Name参数如何,Get-Website都会返回所有网站的信息。看来-Name参数被忽略了。

例如,如果我使用:

Import-Module WebAdministration
Get-Website -Name "Test Website"

我将收到有关机器上所有网站的信息:
Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:
                                                                net.tcp 808:*
                                                                net.pipe *
                                                                net.msmq localhost
                                                                msmq.formatname localhost
Test Website     2    Started    C:\websites\test               http *:80:test.mydomain.com

根据文档,Get-Website应该返回-Name参数中指定的网站的信息。我一定是误解了文档或误用了cmdlet,或两者兼而有之。

如何使用Get-Website返回特定网站的信息?

最佳答案

根据this forum post,这是Get-Website cmdlet中的错误。解决此问题之前的解决方法是使用Get-Item。

$website = "Test"
Get-Item "IIS:\sites\$website"

确保使用双引号,使用单引号时不会扩展变量。

关于iis-7 - Powershell Get-WebSite名称参数被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4170530/

相关文章:

iis-7 - IIS URL 重写 - 友好 URL : Querystring variable is repeated

iis-7 - 用: An error occurred communication with the remote host填满的日志

c++ - 内存映射文件很慢

Powershell 数组、函数和引用

Powershell 4.0 无法从 psm1 导入哈希表

python - 是否可以将 .py 和 .ps1 脚本合并到 .exe 中?

c# - 多个网站,一个公共(public)代码库和不同的配置文件

c# - 是否可以根据 ASP.NET/IIS 中的用户代理进行条件 URL 重写?

windows - 为什么Createprocess返回NULL?

git - 致命的 : unable to access 'H:\/.config/git/config' : Invalid argument [Git on Windows 7]