Tuesday, July 14, 2009

powershell to deploy web application

following script will
  • Create an application pool, it to use 32 bit on x64, change it to use classic pipeline mode
  • Create a web application, point physical path to the path we created, specify the application pool we created, disable anonymous authentication and enable windows authentication
$appName = "IIS:\Sites\Default Web Site\DistributionService"
$appPoolPath = "IIS:\AppPools\DistributionService"
$appPath = "C:\inetpub\wwwroot\DistributionService"
$appLocation = "Default Web Site/DistributionService"
$appPoolName = "DistributionService"

md $appPath

new-item $appPoolPath
$appPool = Get-Item $appPoolPath
$appPool.enable32BitAppOnWin64 = "True"
$appPool.managedPipelineMode = "Classic"
$appPool | Set-Item

New-Item $appName -physicalPath $appPath -type Application
Set-ItemProperty $appName -name applicationPool -value $appPoolName

Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath IIS:\ -location $appLocation
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath IIS:\ -location $appLocation

No comments:

Post a Comment