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

后端 未结 3 1487
无人共我
无人共我 2021-01-17 12:08

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

\"enter

3条回答
  •  生来不讨喜
    2021-01-17 12:54

    If your are running PowerShell (Core), a.k.a PowerShell >v7.1.x, you will find yourself in trouble because...

    WARNING: Module WebAdministration is loaded in Windows PowerShell using WinPSCompatSession remoting session;
    please note that all input and output of commands from this module will be deserialized objects.
    If you want to load this module into PowerShell please use 'Import-Module -SkipEditionCheck' syntax.
    

    The IIS provider isn't available via remoting session.

    The easiest trick is to redirect string via pipeline to Windows PowerShell.

    "Import-Module WebAdministration;New-ItemProperty -Path `"IIS:\Sites\$($configuration.Website.Name)`" -Name Bindings -value @{protocol = `"net.msmq`"; bindingInformation = `"localhost`" }" | PowerShell
    

    In this example, the website name is read from the configuration JSON. You can replace it by a hard-coded site name.

提交回复
热议问题