2010-08-26 1 views
5

Sur l'un de mes serveurs la commande New-WebSite a cessé de fonctionner aujourd'hui (elle fonctionnait bien hier), lançant l'exception " L'index était en dehors des limites du tableau"."PS c: > New-WebSite -Blah:" throws L'index était en dehors des limites du tableau

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 

Est-ce que quelqu'un sait ce qui pourrait avoir causé cela?

+0

essayer http://serverfault.com/ – CoderHawk

Répondre

3

Comme mentionné et a accepté c'est un bug qui apparaît lors de la création d'un nouveau site lorsque IIS n'a pas de sites existants. Étant donné que ce n'est pas très utile pour résoudre le problème est ici la solution que je trouve en creusant à travers le forum figurant dans une autre réponse:

#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 
+0

Merci d'envoyer votre solution. A travaillé comme un champion. Bien joué. – CodeDreamer68

10

Il s'agit d'un bogue dans le commandlet New-WebSite. Apparemment, il doit y avoir au moins un site configuré dans IIS sinon New-WebSite se bloque.

Questions connexes