Created
May 22, 2014 08:24
-
-
Save karaaie/f1d85cac931730944115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
#folder where all your websites are located | |
[string]$webSiteRootFolder = "c:\\websites", | |
#name of site that you're setting up | |
[string]$siteName = "HelloWorld", | |
#the port your default binding is using | |
[string]$port = 8090 | |
) | |
import-module WebAdministration | |
#site folder | |
$siteInstallLocation = "$webSiteRootFolder\\$siteName" | |
#site application pool | |
$siteAppPool = "$siteName-pool" | |
#check if the site is already present (determines update or install) | |
$isPresent = Get-Website -name $siteName | |
if($isPresent){ | |
#upgrade the current package | |
Write-Host "$siteName will be updated" | |
Copy-Item "source/*" -Recurse $siteInstallLocation -Force | |
}else{ | |
#install a clean version of the package | |
Write-Host "$siteName will be installed" | |
#create site folder | |
new-item $siteInstallLocation -ItemType directory -Force | |
#copy site files to site folder | |
Copy-Item "source/*" -Recurse $siteInstallLocation -Force | |
#create application pool | |
New-WebAppPool -Name $siteAppPool -Force | |
#set the alwaysRunning setting to true.(this is needed for workflow to start properly) | |
#to find which path to modify look in the applicationHosts.config file (google for location) | |
Set-WebConfigurationProperty "/system.applicationHost/ApplicationPools/add[@name='$siteAppPool']" -PSPath IIS:\ -Name startMode -Value "AlwaysRunning" | |
#create site | |
New-Website -Name $siteName -Port $port -ApplicationPool $siteAppPool -PhysicalPath $siteInstallLocation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment