Pet*_*erg 5 iis powershell iis-7
在我的一台服务器上,命令New-WebSite今天停止工作(昨天工作正常),抛出异常"索引超出了数组的范围".
PS C:\Windows\system32> Import-Module WebAdministration
PS C:\Windows\system32> New-WebSite -Blah
New-Item : Index was outside the bounds of the array.
+ CategoryInfo : NotSpecified: (:) [New-Item], IndexOutOfRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException,Microsoft.PowerShell.Commands.NewItemCommand
Run Code Online (Sandbox Code Playgroud)
有谁知道这可能导致了什么?
小智 3
正如所提到和接受的,这是在 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1702 次 |
| 最近记录: |