Goal: Update an existing host header for an IIS7.5 site with powershell
Problem: Set-WebBinding
requires the name of t
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}
}
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
}