Hey now,
I'm new to this PowerShell/WebAdministration thing. My script allows a user to enter an IP address for a new website. This IP is used as part of the -bindings argument when the New-Item cmdlet is called. -bindings expects a hash table as the argument type. Thing is, I cannot figure out how to use a variable in the constructor of the hash table. After Googling this issue extensively, I attempted a number of syntactical variations, none of which worked (for clarity, I've omitted the other parameters used by the cmdlet):
-bindings @{label="protocol";Expression="http";label="bindingInformation";Expression={($ip) + ":80"}}
and
-bindings @{"protocol" = "http";"bindingInformation" = {($ip) + ":80"}}
and
-bindings @{"protocol" = "http";"bindingInformation" = ($ip) + ":80"}
All result in a runtime error of some sort. In desperation, I ended up with:
$bindings = @{"protocol" = "http"}
$bindings.Add("bindingInformation", "")
$bindings["bindingInformation"] = $ip + ":80"
then
-bindings $bindings
This ran sucessfully, but the binding information for the new site was empty. What am I doing wrong here?
TIA