From c5bd9f477e99882e840b8f84a22cafd25f96a720 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 14 Jan 2022 23:58:13 +0100 Subject: [PATCH] Fixes method NULL exception on empty EventLog --- doc/31-Changelog.md | 3 +++ provider/eventlog/Get-IcingaEventLog.psm1 | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 6073f6c1..5ac95b80 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -11,7 +11,10 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic [Issue and PRs](https://github.com/Icinga/icinga-powershell-plugins/milestone/11?closed=1) +## Bugfixes + * [#246](https://github.com/Icinga/icinga-powershell-plugins/pull/246) Fixes wrong `UNKNOWN` on `Invoke-IcingaCheckService` while using service display name with the `-Service` argument instead of the service name +* [#262](https://github.com/Icinga/icinga-powershell-plugins/pull/262) Fixes method NULL exception on empty EventLog entries for `Invoke-IcingaCheckEventLog` ## 1.7.0 (2021-11-09) diff --git a/provider/eventlog/Get-IcingaEventLog.psm1 b/provider/eventlog/Get-IcingaEventLog.psm1 index a352e7ee..9b14f537 100644 --- a/provider/eventlog/Get-IcingaEventLog.psm1 +++ b/provider/eventlog/Get-IcingaEventLog.psm1 @@ -253,13 +253,17 @@ function Get-IcingaEventLog() [string]$EventHash = Get-StringSha1 $EventIdentifier; if ($groupedEvents.eventlog.ContainsKey($EventHash) -eq $FALSE) { + [string]$EventMessage = $event.Message; + if ([string]::IsNullOrEmpty($EventMessage)) { + $EventMessage = ''; + } $groupedEvents.eventlog.Add( $EventHash, @{ NewestEntry = $event.TimeCreated; OldestEntry = $event.TimeCreated; EventId = $event.Id; - Message = $event.Message; + Message = $EventMessage; Severity = $ProviderEnums.EventLogSeverityName[$event.Level]; Source = $event.ProviderName; Count = 1;