3

我正在尝试使用以下 PowerShell 脚本,但Length cannot be zero出现错误:

Import-Module WebAdministration

$xml = [xml](Get-Content .\settings.xml)

$websites = $xml.Websites

foreach ($website in $websites.Website){    
   $dnsName = $website.DnsName

....

   #check if the site exists
   if (!(Test-Path "IIS:\Sites\$iisAppName" -pathType container))
   {
    $website = "IIS:\Sites\$($iisAppName)"

    $httpsBindingInformation = "*:443:"+$dnsName
    $bindings = @(@{protocol="net.tcp";bindingInformation="808:*"},@{protocol="https";bindingInformation=$httpsBindingInformation;sslFlags=1})

    $physicalPath = "$($directoryPathPrefix)$($iisAppName)"


    Write-Host "Creating website $($iisAppName)"
    #create the site
    $iisApp = New-Item -path $website -bindings $bindings -physicalPath $physicalPath
   }
}

完整的错误消息如下:

New-Item : Length cannot be less than zero.
Parameter name: length
At D:\CreateWebSites.ps1:51 char:13
+         $iisApp = New-Item -path $website -bindings $bindings -physicalPath $physicalP ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [New-Item], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : Length cannot be less than zero.
Parameter name: length,Microsoft.PowerShell.Commands.NewItemCommand

我无法找出它抱怨的参数。New-Item没有参数Length...任何提示?

4

0 回答 0