我想使用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/