Skip to content

Commit 4a77fce

Browse files
committed
Fixes Agent installer exception on file checks
Fixes #183
1 parent 4e6a968 commit 4a77fce

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1818
* [#186](https://github.com/Icinga/icinga-powershell-framework/issues/186) Fixes path handling for custom local/web path sources for service binary installation
1919
* [#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
2020
* [#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`
21+
* [#195](https://github.com/Icinga/icinga-powershell-framework/pull/195) Fix Agent installer crash on package lookup with different files in directory
2122

2223
## 1.3.0 (2020-12-01)
2324

lib/core/icingaagent/getters/Get-IcingaAgentMSIPackage.psm1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ function Get-IcingaAgentMSIPackage()
2626
$Content = Get-ChildItem -Path $Source;
2727

2828
foreach ($entry in $Content) {
29-
$PackageVersion = ($entry.Name.Split('-')[1]).Replace('v', '');
29+
# Only check for MSI packages
30+
if ($entry.Extension.ToLower() -ne '.msi') {
31+
continue;
32+
}
33+
34+
$PackageVersion = '';
35+
36+
if ($entry.Name.ToLower().Contains('-')) {
37+
$PackageVersion = ($entry.Name.Split('-')[1]).Replace('v', '');
38+
}
3039

3140
if ($Version -eq 'snapshot') {
3241
if ($PackageVersion -eq 'snapshot') {
@@ -40,8 +49,12 @@ function Get-IcingaAgentMSIPackage()
4049
continue;
4150
}
4251

43-
if ($null -eq $UseVersion -Or [version]$PackageVersion -ge [version]$UseVersion) {
44-
$UseVersion = $PackageVersion;
52+
try {
53+
if ($null -eq $UseVersion -Or [version]$PackageVersion -ge [version]$UseVersion) {
54+
$UseVersion = $PackageVersion;
55+
}
56+
} catch {
57+
# Nothing to catch specifically
4558
}
4659
}
4760
} else {

0 commit comments

Comments
 (0)