From 407b6ff1d5d1aa6eebcbaffb7ffbd8f0b1a06326 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Thu, 14 Dec 2017 10:38:34 +0100 Subject: [PATCH] Try to create EventLog source if not existing. --- Updater/Update-Service.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index 6657a90..6d94025 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -386,6 +386,16 @@ catch { Exit } +if (-Not ([System.Diagnostics.EventLog]::SourceExists($ServiceName))) { + try { + New-EventLog -LogName Application -Source $ServiceName + } + catch { + $ex = $_.Exception.Message + Write-Verbose "Error creating event log source: $($ex)" + } +} + # NOTE: $MyInvocation is not available when run as ScheduledJob, so we have to # set a shortcut for our name explicitly ourselves here: -- GitLab