Created
August 27, 2013 18:34
-
-
Save andreasohlund/6357270 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $service = Get-Service "the service" -ErrorAction SilentlyContinue | |
| if ($service) | |
| { | |
| "Backend service is already installed, going to uninstall first" | |
| #get the path to the current service | |
| $servicePath = "HKLM:SYSTEM\CurrentControlSet\Services\$service" | |
| $serviceKey = get-itemproperty -path $servicePath -ErrorAction silentlycontinue | |
| $imagePath = $serviceKey.psobject.properties | ?{ $_.Name -eq 'ImagePath' } | |
| $pos = $imagePath.value.IndexOf("NServiceBus.Host.exe") + 22 | |
| $uninstallCommand = $imagePath.value.Substring(0, $pos).Replace('"','') + " /uninstall /endpointName:+$service /serviceName:$service" | |
| "Uninstalling the previous service: " + $uninstallCommand | |
| iex $uninstallCommand | Write-Host | |
| } | |
| "The service will be installed" | |
| .\NServiceBus.Host.exe /install /endpointName:$service /serviceName:$service | Write-Host | |
| "The service installed, will set recovery options" | |
| sc.exe failure $service reset= 86400 actions= restart/120000/restart/120000/restart/120000 | |
| "Deploy completed successfully" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment