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

前端之家收集整理的这篇文章主要介绍了iis-7 – Powershell Get-WebSite名称参数被忽略前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用PowerShell Get-Website cmdlet检索有关特定IIS 7网站的信息。不幸的是,Get-Website返回所有网站的信息,而不管我传入的-Name参数。看起来-Name参数被忽略。

例如,如果我使用:

  1. Import-Module WebAdministration
  2. Get-Website -Name "Test Website"

我将收到我机器上所有网站的信息:

  1. Name ID State Physical Path Bindings
  2. ---- -- ----- ------------- --------
  3. Default Web Site 1 Started %SystemDrive%\inetpub\wwwroot http *:80:
  4. net.tcp 808:*
  5. net.pipe *
  6. net.msmq localhost
  7. msmq.formatname localhost
  8. 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。
  1. $website = "Test"
  2. Get-Item "IIS:\sites\$website"

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

猜你在找的Windows相关文章