Update Host Header in IIS with Powershell


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

Problem: Set-WebBinding requires the name of the site which I don’t have. I do have the HostHeader though.

Scenario: I have multiple sites in IIS. Some of them have a host header with a particular string that I want to change.

I want to change all sites that have .stuff in their headers.

I’m using Get-WebBinding to get a list of all sites and their bindings. I then loop through them and check if bindingInformation contains .stuff. I modify the string how I please and then go to update the header with

Apparently though, you have to have the site’s name in order to use Set-WebBinding, unlike Get-WebBinding which allows you to get a binding based on the HostHeader (Get-WebBinding -HostHeader $someValue). Is there a way to use Set-WebBinding without specifing the Name of a site? Is there a way I can get the site’s name from Get-WebBinding? Is there an alternative to Set-WebBinding? Or is there a better way to do what I’m trying to do?


Give this a try:


Update Host Header in IIS with Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply