From 8304ebbd09ab9010d6d440cac14c74a6ac8a02bc Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 5 Mar 2018 14:51:25 +0100 Subject: [PATCH] Define ServiceLog as a global variable. --- Scripts/Install-Service.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/Install-Service.ps1 b/Scripts/Install-Service.ps1 index ae473b3..c099c0e 100644 --- a/Scripts/Install-Service.ps1 +++ b/Scripts/Install-Service.ps1 @@ -36,7 +36,7 @@ function Start-MyService { Write-Host "Please check if your configuration is valid!" Write-Host "Showing last 20 lines of service log file:" Write-Host "==========================================" - Get-Content "$($ServiceDir)\service.log" -Tail 20 + Get-Content $ServiceLog -Tail 20 } } @@ -66,8 +66,8 @@ function Copy-ServiceFiles { Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir -ErrorAction Stop Copy-FileIfNew "configuration.xml" $ServiceDir Copy-FileIfNew "status.xml" $ServiceDir - Copy-FileIfNew "service.log" $ServiceDir - Clear-Content "$($ServiceDir)\service.log" + Copy-FileIfNew "service.log" $ServiceLog + Clear-Content $ServiceLog Write-Host "[OK]" -Fore Green } catch { @@ -100,6 +100,7 @@ if (Test-Path $LocalConfiguration) { Exit } +$ServiceLog = "$($ServiceDir)\$($ServiceName).log" try { $Service = Get-Service $ServiceName -ErrorAction Stop -- GitLab