Last active
October 4, 2016 11:00
Star
You must be signed in to star a gist
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
Configuration Main | |
{ | |
Import-DscResource –ModuleName 'PSDesiredStateConfiguration' | |
Node ('localhost') | |
{ | |
Script DeployWindowsService | |
{ | |
GetScript = { | |
@{ | |
Result = "" | |
} | |
} | |
TestScript = { | |
$false | |
} | |
SetScript = { | |
$serviceName = "ResponseProcessor" | |
$displayName = "Simon Demonstration Response Processor" | |
# location where our AzureVMs File Copy RM Task copies our build outputs | |
$sourceLocation = "C:\temp\*" | |
$destinationLocation = "C:\Program Files\Simon\PaymentProcessorService\" | |
$binaryName = $destinationLocation + "Simon.Demo.ClearanceProcessor.exe" | |
$serviceDef = Get-Service -Name $serviceName -ErrorAction SilentlyContinue | |
If ($serviceDef -eq $null) | |
{ | |
# first install - create directory | |
New-Item $destinationLocation -ItemType directory | |
Copy-Item $sourceLocation $destinationLocation -Force | |
New-Service -Name $serviceName -StartupType Automatic -DisplayName $displayName -BinaryPathName $binaryName | |
} | |
else | |
{ | |
# has already been installed | |
if($serviceDef.Status -eq "Running") | |
{ | |
Stop-Service -Name $serviceName | |
} | |
Copy-Item $sourceLocation $destinationLocation -Force | |
} | |
Start-Service -Name $serviceName | |
} | |
} | |
} | |
} | |
Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment