Deployment mit Powershell – Schritt 5: Einrichten von Webseiten im IIS.

by robert 10. May 2009 13:30

Nun geht es darum die kopierte Webseite auch im IIS einzurichten. Da der redundante Server auf EC2 noch als Windows 2003 Maschine läuft muss das Script sowohl IIS6 als IIS7 unterstützen. (Ob durch Azure, EC2 niemals von Hause aus Windows 2008 Instanzen unterstützen wird?). Duch die benötigte Rückwertskompatibilität setzen wir daher WMI ein.

function IISCreateWebSite
{    
    $service = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebService"
    
    $bindingClass = [wmiclass]'root\MicrosoftIISv2:ServerBinding'
    $bindings = $bindingClass.CreateInstance()
    $bindings.IP = ""
    $bindings.Port = "80"
    $bindings.Hostname = $iis_app_hostheader
 
    $result = $service.CreateNewSite($iis_app_name, $bindings, $path_targetDeployment)
}

Die Umsetzung war verblüffend einfach und in 10 Minuten geschafft (Dank  GBP “Google Based Programming”). Die Variablen sind nach bester Programmierermanier global.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.