From aa8d712152945e719396d6a727a646dc9dd655c7 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 28 Jul 2020 17:53:40 +0200 Subject: [PATCH] Fix conversion error on ConvertTo-Seconds while input is $null Fixes #84 --- doc/31-Changelog.md | 1 + lib/core/tools/ConvertTo-Seconds.psm1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index f86f593..9b32a6e 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -20,6 +20,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#78](https://github.com/Icinga/icinga-powershell-framework/issues/78) Fix Icinga Agent package fetching for x86 architecture * [#79](https://github.com/Icinga/icinga-powershell-framework/issues/79) Fix ConvertTo-Seconds to output valid numeric data with multiple digits * [#81](https://github.com/Icinga/icinga-powershell-framework/issues/81), [#82](https://github.com/Icinga/icinga-powershell-framework/issues/82) Fix error on EventLog initialising in case `Icinga for Windows` application is not registered on new machines +* [#84](https://github.com/Icinga/icinga-powershell-framework/issues/84), Fix conversion of `ConvertTo-Seconds` and `ConvertTo-SecondsFromIcingaThresholds` while the input value is `$null` ## 1.1.2 (2020-07-01) diff --git a/lib/core/tools/ConvertTo-Seconds.psm1 b/lib/core/tools/ConvertTo-Seconds.psm1 index 59bd7aa..b7ee663 100644 --- a/lib/core/tools/ConvertTo-Seconds.psm1 +++ b/lib/core/tools/ConvertTo-Seconds.psm1 @@ -107,7 +107,7 @@ function ConvertTo-SecondsFromIcingaThresholds() [string]$Value = [string]::Join(':', $NewContent); - if ($Value.Contains(':') -eq $FALSE) { + if ([string]::IsNullOrEmpty($Value) -eq $FALSE -And $Value.Contains(':') -eq $FALSE) { return [convert]::ToDouble($Value); }