From 4944a57eed55438035b27ccbd38ac037f9741c4d Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 5 Mar 2018 16:01:33 +0100 Subject: [PATCH] Only start the service if explicitly requested via a switch. This is only useful if the package actually contains configuration files for the given host. If that's the case use the switch, otherwise a message about how to start it will be printed to the console. --- Scripts/Install-Service.ps1 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Scripts/Install-Service.ps1 b/Scripts/Install-Service.ps1 index 0ed3464..92d943f 100644 --- a/Scripts/Install-Service.ps1 +++ b/Scripts/Install-Service.ps1 @@ -4,6 +4,10 @@ #Requires -version 5.1 #Requires -RunAsAdministrator +[CmdletBinding()] +Param( + [Parameter(Mandatory=$False)][switch] $StartService +) function Start-MyService { Write-Host -NoNewLine "Starting service $($ServiceName): " @@ -97,4 +101,15 @@ if ($Service) { Copy-ServiceFiles Install-Service -Start-MyService + +Write-Host "`nWatching the service log file can be done like this:`n" ` + "`n> Get-Content -Wait -Tail 50 $($ServiceLog)`n" + +if ($StartService) { + Start-MyService +} else { + Write-Host "Service installation has completed.`n" ` + "`nNOTE: the service has not been started. Create and/or check`n" ` + "the configuration files and start the service manually using:`n" ` + "`n> Start-Service $($ServiceName)`n" +} \ No newline at end of file -- GitLab