Adding multiple host headers to IIS 7 – One Liner

When we have to add multiple host headers to a website, we have the “classic” way, ie using the ‘New-WebBinding’ cmdlet in a ‘ForEach’ loop, like this:

ForEach ($hostheader in $hostheaders) {
New-WebBinding -Name $Website -IPAddress $IPAddress -Port $Port -HostHeader $HostHeader

But I’d rather something simpler (I hope!):

Import-Module WebAdministration
Import-CSV hostheaders.csv | New-WebBinding

with a ‘hostheaders.csv’ file formatted as follows:

"Default Web Site",80,"",""
"Default Web Site",80,"",""

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top