Skip to content

Instantly share code, notes, and snippets.

@kimgunnarsson
Created October 7, 2015 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimgunnarsson/0de34ef829a41707759a to your computer and use it in GitHub Desktop.
Save kimgunnarsson/0de34ef829a41707759a to your computer and use it in GitHub Desktop.
PreDeploy.ps1
Import-Module WebAdministration
if($SiteNamesForDeploy) {
$sitesForDeploy = $SiteNamesForDeploy.Split(',')
for ($i=0; $i -lt $sitesForDeploy.length; $i++) {
$currentSite = $sitesForDeploy[$i].Trim()
Write-Output "Stop-Website $currentSite"
try {
Start-Website $currentSite
} catch {
Write-Output "Could not run command Start-Website $currentSite"
Exit 1
}
}
Exit 0
} else {
Write-Output "Variable 'SiteNamesForDeploy' is not set - failing action Start-Website"
Exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment