-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreAction.ps1
More file actions
41 lines (29 loc) · 999 Bytes
/
PreAction.ps1
File metadata and controls
41 lines (29 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Set-StrictMode -v latest
$ErrorActionPreference = "Stop"
[string] $transcriptfilePre = Join-Path (pwd).Path "pre_transcript.log"
[string] $logfilePre = Join-Path (pwd).Path "pre_action.log"
Start-Transcript -Path $transcriptfilePre -Append
function Main() {
Import-Module "IISAdministration"
[string] $serviceName = "OctopusDeploy"
Log "Stopping service: '$serviceName'"
Stop-Service $serviceName
Start-Sleep 10
[string] $poolName = "DefaultAppPool"
[string] $siteName = "Default Web Site"
Log "Starting pool: '$poolName'"
$pool = Get-IISAppPool $poolName
$pool.Start()
Log "Starting website: '$siteName'"
Start-IISSite $siteName
}
function Log([string] $message, $color) {
([DateTime]::UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + ": " + $message) | Add-Content $logfilePre
if ($color) {
Write-Host $message -f $color
}
else {
Write-Host $message -f Green
}
}
Main