Update Host Header in IIS with Powershell

前端 未结 2 1455
忘了有多久
忘了有多久 2021-01-13 03:43

Goal: Update an existing host header for an IIS7.5 site with powershell

Problem: Set-WebBinding requires the name of t

相关标签:
2条回答
  • 2021-01-13 04:35

    Give this a try:

    Get-WebBinding -HostHeader *.stuff.* | Foreach-Object{
        #$NewHeader = $_.bindingInformation -replace '\.stuff\.','.staff.'
        Set-WebConfigurationProperty -Filter $_.ItemXPath -PSPath IIS:\ -Name Bindings -Value @{protocol='http';bindingInformation=$NewHeader}
    }
    
    0 讨论(0)
  • 2021-01-13 04:40

    Modified Shay's answer to support multiple bindings.

    Get-WebBinding -HostHeader *.stuff.* | Foreach-Object{
        #$NewHeader = $_.bindingInformation -replace '\.stuff\.','.staff.'
        Set-WebConfigurationProperty -Filter ($_.ItemXPath + "/bindings/binding[@protocol='http' and @bindingInformation='" + $_.bindingInformation + "']") -PSPath IIS:\ -Name bindingInformation -Value $NewHeader
    }
    
    0 讨论(0)
提交回复
热议问题