Skip to content

Instantly share code, notes, and snippets.

@sheastrickland
Created March 20, 2015 06:19
Show Gist options
  • Save sheastrickland/f83bab270e4915ec50e3 to your computer and use it in GitHub Desktop.
Save sheastrickland/f83bab270e4915ec50e3 to your computer and use it in GitHub Desktop.
Application Initialization config for deployments
# Load IIS module:
Import-Module WebAdministration
# Set a name of the site we want to change
$webSiteName = $OctopusParameters['OctopusWebSiteName']
# Get web site object
$webSite = Get-Item "IIS:\Sites\$webSiteName"
Write-Output "Setting IIS web site $webSiteName serverAutoStart to true"
$webSite.serverAutoStart="true"
$webSite | Set-Item
Write-Output "Setting IIS web site $webSiteName root application preloadEnabled to true"
Set-WebConfigurationProperty "/system.applicationHost/sites/site[@name='$webSiteName']/application" -Name "preloadEnabled" -Value "true" -PSPath IIS:\
# Set a name of the appPool we want to change
$applicationPoolName = $OctopusParameters['OctopusAppPoolName']
Write-Output "Setting IIS AppPool $applicationPoolName autoStart to true and startMode to AlwaysRunning."
$pool = Get-Item IIS:\AppPools\"$applicationPoolName"
$pool.autoStart="true"
$pool.startMode="AlwaysRunning"
$pool | Set-Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment