Iis &引用;PS c:\>;新网站-废话;抛出索引超出了数组的边界

Iis &引用;PS c:\>;新网站-废话;抛出索引超出了数组的边界,iis,iis-7,powershell,Iis,Iis 7,Powershell,在我的一台服务器上,命令New-WebSite今天停止工作(昨天工作正常),抛出异常“索引超出数组边界” 有人知道这可能是什么原因吗?这是新网站commandlet中的一个bug。显然,必须在IIS中至少配置一个站点,否则新网站将崩溃。这也可以通过使用: New-Website -Name Blah -Id [xxx] 请参阅:如前所述,这是在IIS没有现有站点时创建新站点时出现的错误。由于这对解决问题没有多大帮助,因此我在另一个答案中列出的问题中找到了以下解决方案: #This line w

在我的一台服务器上,命令New-WebSite今天停止工作(昨天工作正常),抛出异常“索引超出数组边界”


有人知道这可能是什么原因吗?

这是新网站commandlet中的一个bug。显然,必须在IIS中至少配置一个站点,否则新网站将崩溃。

这也可以通过使用:

New-Website -Name Blah -Id [xxx]

请参阅:

如前所述,这是在IIS没有现有站点时创建新站点时出现的错误。由于这对解决问题没有多大帮助,因此我在另一个答案中列出的问题中找到了以下解决方案:

#This line will get the highest id of any existing sites and add one to it (or start you off at 1)
$id = (dir iis:\sites | foreach {$_.id} | sort -Descending | select -first 1) + 1
$webSite = New-Website -Name "$name" -PhysicalPath "$physicalPath" -ApplicationPool "$applicationPool" -Port "$port" -IPAddress "$IPAddress" -HostHeader "$hostName" -id $id

感谢您发布您的解决方案。像冠军一样工作。做得好。
#This line will get the highest id of any existing sites and add one to it (or start you off at 1)
$id = (dir iis:\sites | foreach {$_.id} | sort -Descending | select -first 1) + 1
$webSite = New-Website -Name "$name" -PhysicalPath "$physicalPath" -ApplicationPool "$applicationPool" -Port "$port" -IPAddress "$IPAddress" -HostHeader "$hostName" -id $id