diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index e6d438d..898b2ad 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 * [#186](https://github.com/Icinga/icinga-powershell-framework/issues/186) Fixes path handling for custom local/web path sources for service binary installation * [#188](https://github.com/Icinga/icinga-powershell-framework/pull/188) Removes hardcoded zones `director-global` and `global-zones` which were always set regardless of user specification. This fix will ensure the user has the option to add or not add these zones * [#189](https://github.com/Icinga/icinga-powershell-framework/pull/189) Fixes wrong documented user group for accessing Performance Counter objects which should be `Performance Monitor Users` +* [#195](https://github.com/Icinga/icinga-powershell-framework/pull/195) Fix Agent installer crash on package lookup with different files in directory ## 1.3.0 (2020-12-01) diff --git a/lib/core/icingaagent/getters/Get-IcingaAgentMSIPackage.psm1 b/lib/core/icingaagent/getters/Get-IcingaAgentMSIPackage.psm1 index b6450e0..3dde0a2 100644 --- a/lib/core/icingaagent/getters/Get-IcingaAgentMSIPackage.psm1 +++ b/lib/core/icingaagent/getters/Get-IcingaAgentMSIPackage.psm1 @@ -26,7 +26,16 @@ function Get-IcingaAgentMSIPackage() $Content = Get-ChildItem -Path $Source; foreach ($entry in $Content) { - $PackageVersion = ($entry.Name.Split('-')[1]).Replace('v', ''); + # Only check for MSI packages + if ($entry.Extension.ToLower() -ne '.msi') { + continue; + } + + $PackageVersion = ''; + + if ($entry.Name.ToLower().Contains('-')) { + $PackageVersion = ($entry.Name.Split('-')[1]).Replace('v', ''); + } if ($Version -eq 'snapshot') { if ($PackageVersion -eq 'snapshot') { @@ -40,8 +49,12 @@ function Get-IcingaAgentMSIPackage() continue; } - if ($null -eq $UseVersion -Or [version]$PackageVersion -ge [version]$UseVersion) { - $UseVersion = $PackageVersion; + try { + if ($null -eq $UseVersion -Or [version]$PackageVersion -ge [version]$UseVersion) { + $UseVersion = $PackageVersion; + } + } catch { + # Nothing to catch specifically } } } else {