From 14f743851e9c84bb3d7f758f205f45ddfc64c495 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 5 Feb 2018 14:27:19 +0100 Subject: [PATCH] Read the host alias from config and include in updater notification. Refers to #13 --- Updater/Update-Service.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index 5a70ec8..d63e287 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -307,7 +307,26 @@ function Upload-LogFiles { } +function Get-HostDescription() { + $Desc = $env:COMPUTERNAME + $ConfigXml = "$($InstallationPath)\configuration.xml" + try { + [xml]$XML = Get-Content $ConfigXml -ErrorAction Stop + # careful, we need a string comparison here: + $Desc += " ($($XML.ServiceConfig.HostAlias))" + } + catch { + $ex = $_.Exception.Message + $msg = "Trying to read the service config from [$($ConfigXml)] failed! " + $msg += "The reported error message was:`n$($ex)" + Log-Error $msg + } + Return $Desc +} + + function Send-MailReport([string]$Subject, [string]$Body) { + $Body = "Notification from $(Get-HostDescription)`n`n$($Body)" $Subject = "[$($Me)] $($env:COMPUTERNAME) - $($Subject)" $msg = "------------------------------`n" $msg += "From: $($EmailFrom)`n" -- GitLab