Created
August 30, 2018 13:22
-
-
Save sitereactor/dcf056722a6beb79b217087258a7b225 to your computer and use it in GitHub Desktop.
Modified Powershell script for installing TopShelf-based Windows Services through Octopus Deploy. This script has been updated with an ArgumentList that works with username and password passed in from Variables.
This file contains 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
$step = $OctopusParameters['Unpackage step'] | |
$username = $OctopusParameters['Username']; | |
$password = $OctopusParameters['Password']; | |
$customExeFilename = $OctopusParameters['Exe filename']; | |
$outputPath = $OctopusParameters["Octopus.Action[$step].Package.CustomInstallationDirectory"] | |
if(!$outputPath) | |
{ | |
$outputPath = $OctopusParameters["Octopus.Action[$step].Output.Package.InstallationDirectoryPath"] | |
} | |
$defaultExeFilename = $OctopusParameters["Octopus.Action[$step].Package.NuGetPackageId"] + ".exe" | |
$exeFilename = If ($customExeFilename) {$customExeFilename} Else {$defaultExeFilename} | |
$path = Join-Path $outputPath $exeFilename | |
if(-not (Test-Path $path) ) | |
{ | |
Throw "$path was not found" | |
} | |
Write-Host "Installing from: $path" | |
if(!$username) | |
{ | |
Start-Process $path -ArgumentList "install" -NoNewWindow -Wait | Write-Host | |
} | |
else | |
{ | |
Start-Process $path -ArgumentList "install -username `"$username`" -password `"$password`" " -NoNewWindow -Wait | Write-Host | |
} | |
Start-Process $path -ArgumentList "start" -NoNewWindow -Wait | Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment