Powershell WebAdminstration New-Item:长度不能为零

时间:2015-12-03 10:23:19

标签: powershell iis web-administration

我尝试使用以下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 ...有任何提示吗?

0 个答案:

没有答案