« Previous Next »

Thread: Setting binding information with a dynamic IP address

Last post 11-03-2009 3:10 AM by Leo Tang - MSFT. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 10-30-2009, 10:37 AM

    • cmdcom
    • Not Ranked
    • Joined on 10-30-2009, 2:13 PM
    • Posts 1

    Setting binding information with a dynamic IP address

    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

     

  • 11-03-2009, 3:10 AM In reply to

    Re: Setting binding information with a dynamic IP address

    Hi,

    Please do not use double quotation marks on the properties' name(for example: "protocol", "bindingInformation"), then test again.

    Below is an article about  some PowerShell cmdlets, hope helps :
    PowerShell Snap-in: Making Simple Configuration Changes to Web-Sites and Application Pools
    http://forums.iis.net/t/1162211.aspx

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (2 items)
Microsoft Communities