Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Powershell's New-WebBinding commandlet creates incorrect HostHeader?

I am trying to add an MSMQ binding for my IIS Web Site, correct binding should look like this:

enter image description here

So I am executing following line in PowerShell:

New-WebBinding -Name "My Site"  -Protocol net.msmq -HostHeader "localhost"

and it creates the following binding:

enter image description here

prefixing it with *:80:, so my MSMQ messages don't get picked up by WCF service. Maybe I am doing it wrong? How to create a binding with Binding Information set to just "localhost" using this PowerShell comandlet?

Commandlet codumentaiton can be found here.

like image 738
Restuta Avatar asked Feb 24 '12 02:02

Restuta


2 Answers

Looking at the decompiled code of the cmdlet, looks like it adding the IPAddress and Port information in the binding and there is no workaround to it.

Relevant sections from the code:

private string ipAddress = "*";
...
builder.Append(this.ipAddress);
...
builder.Append(":" + this.sitePort.ToString(CultureInfo.InvariantCulture) + ":");

But you can do what the cmdlet actually does ( below code from cmdlet):

new-itemproperty -path "IIS:\sites\test" -name bindings -value @{protocol="net.msmq"; bindingInformation="localhost"}
like image 52
manojlds Avatar answered Oct 15 '22 01:10

manojlds


Give this a try:

New-ItemProperty "IIS:\sites\NameOfYourSite" -name bindings -value @{protocol="net.msmq";bindingInformation="localhost"}
like image 32
Andy Arismendi Avatar answered Oct 15 '22 02:10

Andy Arismendi