Is there anyway to edit this script to work with IIS 6.0 in Windows server 2003?
This is my final script.
Param
( [String] $Customername = $(Throw "You must enter a customer name"),
[String] $Projectname = $(Throw "You must enter a project name"),
[String]$Path="c:\inetpub\wwwroot\$Customername\$Projectname\website\wwwroot", #The Physical Path of the site
[String]$AppPool="DefaultAppPool", #The name of the appPool the default app is part of
[Int]$SiteID = $(Throw "You must enter a site id number"),
[String]$PhysicalPath="c:\inetpub\wwwroot\$Customername\$Projectname\website\wwwroot", #The Applications Physical Path
[String]$RelativePath="/sitemanager", #The Applications Relative Path
[string]$ip = $(Throw "You must enter an ip"),
[string]$hostheader = $(Throw "You must enter an ip")
)
mkdir "C:\inetpub\wwwroot\$customername\$projectname\website\wwwroot"
mkdir "C:\inetpub\wwwroot\$customername\$projectname\website\sitemanager"
[String]$Name=("{0} {1}" -f $Customername,$ProjectName)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$iis = new-object Microsoft.Web.Administration.ServerManager
$Site = $iis.Sites.Add($Name, $Path, 80)
$Site.ServerAutoStart = $true
$Site = $iis.Sites.CreateElement()
$Site.ID = $SiteID
$Site.Name = $Name
$Site.Applications.Add("/", $Path)
$Site.Applications["/"].ApplicationPoolName = $AppPool
#$iis.Sites.Add($Site)
$iis.CommitChanges()
#Reference the Microsoft.Web.Administration namespace
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$iis = new-object Microsoft.Web.Administration.ServerManager
#Add the Application to the site
$iis.Sites[$Name].Applications.Add($RelativePath, $PhysicalPath)
$iis.CommitChanges()
Write-Host $AppPool
#Add the application to the appPool
$iis.Sites[$Name].Applications[$RelativePath].ApplicationPoolName = $AppPool
$iis.CommitChanges()
Thanks in advance.