title: Update Host Header in IIS with Powershell
body: <p><strong>Goal</strong>: Update an existing host header for an IIS7.5 site with powershell</p>
  
  <p><strong>Problem</strong>: <code>Set-WebBinding</code> requires the name of the site which I don't have. I do have the HostHeader though.</p>
  
  <p><strong>Scenario</strong>: I have multiple sites in IIS. Some of them have a host header with a particular string that I want to change.</p>
  
  <pre><code>Site1 - site1.stuff.domain.net
  Site2 - site2.stuff.domain.net
  Site3 - site3.domain.net
  </code></pre>
  
  <p>I want to change all sites that have <code>.stuff</code> in their headers.</p>
  
  <p>I'm using <code>Get-WebBinding</code> to get a list of all sites and their bindings. I then loop through them and check if <code>bindingInformation</code> contains <code>.stuff</code>. I modify the string how I please and then go to update the header with</p>
  
  <pre><code>Set-WebBinding -HostHeader $originalHeader -SetProperty HostHeader -Value $newHeader
  </code></pre>
  
  <p>Apparently though, you have to have the site's name in order to use <code>Set-WebBinding</code>, unlike <code>Get-WebBinding</code> which allows you to get a binding based on the HostHeader (<code>Get-WebBinding -HostHeader $someValue</code>). Is there a way to use <code>Set-WebBinding</code> without specifing the <code>Name</code> of a site? Is there a way I can get the site's name from <code>Get-WebBinding</code>? Is there an alternative to <code>Set-WebBinding</code>? Or is there a better way to do what I'm trying to do?</p>