cm27
cm27

Reputation: 51

powershell script to apply host header name to an existing binding of a site in IIS

I want to apply host header name to an existing binding of a site in IIS. So far i got this command but it creates a new binding but i want to apply the hostheader to the existing one. Below is the command:

new-webbinding -hostheader hostheadername -name sitename -protocol http

Is there any command to do this?

any help would be highly appreciated.

Upvotes: 0

Views: 3972

Answers (2)

Matt Borja
Matt Borja

Reputation: 1577

You can easily construct this yourself using Set-WebBinding.

Example:

Import-Module WebAdministration;
Set-WebBinding -Name "www.example.com" -HostHeader "original.example.com" -PropertyName "HostHeader" -Value "new.example.com"

Upvotes: 1

Ikruzzz
Ikruzzz

Reputation: 258

Did you tried using the set command

set -webbinding -hostheader hostheadername -name sitename

Upvotes: 0

Related Questions