Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Last active August 29, 2015 14:19
Show Gist options
  • Save Dalmirog-zz/c47a178cd2a4654f4fec to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/c47a178cd2a4654f4fec to your computer and use it in GitHub Desktop.
Script For Harbinder
$webSiteName = $OctopusParameters['Octopus.Action[Deploy Workware Legacy].IISWebSite.WebSiteName']
$appPoolName = $OctopusParameters['Octopus.Action[Deploy Workware Legacy].IISWebSite.WebSiteName']
Write-Output "Web Site: $webSiteName"
Write-Output "App Pool: $appPoolName"
Import-Module WebAdministration -Force
$webSite = Get-Website -Name $webSiteName
$appPool = Get-Item "IIS:\AppPools\$appPoolName" -ErrorAction SilentlyContinue
if ($webSite)
{
Write-Output "Stopping Website: $($WebSite.name)"
Stop-Website $webSite.name
}
else
{
Write-Output "Website not found on $($env:computername): $webSiteName"
}
If($appPool)
{
If ($appPool.state -ne "Stopped")
{
Write-Output "Stopping AppPool: $($AppPool.name)"
Stop-WebAppPool $appPool.Name
}
else
{
Write-Output "AppPool was already stopped: $($appPool.name)"
}
}
else{
Write-Output "AppPool not found on $($env:computername): $appPoolName"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment