Reputation: 2698
I'm trying to use the following PowerShell script but get Length cannot be zero
error:
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
}
}
Full error message is following:
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
I cannot find out which parameter it is complaining about. New-Item
has no parameter Length
... Any hints?
Upvotes: 3
Views: 825