Release Management 12 - Creating a website with a host header

Is there a way to create a website with Release Management v12 that will include a host header parameter?

My goal is to be able to host multiple sites on the same server, all bindings to port 80 with different host headers. i.e. http: //project1.development.local/ , http: //project2.development.local/

I can create a website with a host header from AppCmd.exe, but this requires administrator rights. Thought of using powershell, but the UAC prompt will be triggered.

At the moment, I need to manually create a server website to include the host header, and I would like to fully automate the release process.

TIA!

+4
source share
1 answer

There is nothing in this, but, with luck, I hacked something together to handle site bindings:

param( 
$SiteName=$(throw "Site Name must be entered"), 
$HostHeader,
$IpAddress,
$Port,
$RemoveDefault=$(throw "You must specify true or false") 
) 


Import-Module WebAdministration 

try { 
  $bindingExists = (Get-WebBinding "$SiteName" -Port "$Port" -Protocol "http" -HostHeader "$HostHeader" -IPAddress "$IpAddress") 

  if (!$bindingExists) { 
      Write-host "Creating binding for $SiteName : Host header $HostHeader and IP Address $IpAddress" 
      New-WebBinding "$SiteName" -Port $Port -Protocol "http" -HostHeader "$HostHeader" -IPAddress "$IpAddress" 

  } 
  else { 
      Write-host "Site $SiteName already has binding for host header $HostHeader and IP Address $IpAddress" 
  } 

  if ($RemoveDefault -eq "true") { 
      $defaultBinding = Get-WebBinding "$SiteName" | where {$_.bindingInformation -eq "*:80:" } 
      if ($defaultBinding -ne $null) { 
          Write-Host "Default binding exists... removing." 
          $defaultBinding | Remove-WebBinding 
      } 
      else { 
          Write-Host "Default binding does not exist" 
      } 
  } 
} 
catch { 
  Write-host $_ 
  exit 1 
} 
exit 0 

You can create your own tool in RM to use this script, just pass the parameters specified in the block to it param.

You will never have to use AppCmd.exe ... If the built-in tools do not meet your needs, the PowerShell WebAdministration module should be able to do the rest.

+4
source

Source: https://habr.com/ru/post/1538066/


All Articles