diff --git a/lib/core/icingaagent/installer/Install-IcingaAgent.psm1 b/lib/core/icingaagent/installer/Install-IcingaAgent.psm1 index cd5d004..7490a12 100644 --- a/lib/core/icingaagent/installer/Install-IcingaAgent.psm1 +++ b/lib/core/icingaagent/installer/Install-IcingaAgent.psm1 @@ -7,11 +7,6 @@ function Install-IcingaAgent() [bool]$AllowUpdates = $FALSE ); - $IcingaData = Get-IcingaAgentInstallation; - $InstalledVersion = Get-IcingaAgentVersion; - $IcingaInstaller = Get-IcingaAgentMSIPackage -Source $Source -Version $Version -SkipDownload; - $InstallTarget = $IcingaData.RootDir; - if ([string]::IsNullOrEmpty($Version)) { Write-Host 'No Icinga Agent version specified. Skipping installation.'; return $FALSE; @@ -22,6 +17,11 @@ function Install-IcingaAgent() return $FALSE; } + $IcingaData = Get-IcingaAgentInstallation; + $InstalledVersion = Get-IcingaAgentVersion; + $IcingaInstaller = Get-IcingaAgentMSIPackage -Source $Source -Version $Version -SkipDownload; + $InstallTarget = $IcingaData.RootDir; + if ($Version -eq 'snapshot') { if ($IcingaData.InstallDate -ge $IcingaInstaller.LastUpdate -And [string]::IsNullOrEmpty($InstalledVersion.Snapshot) -eq $FALSE) { Write-Host 'There is no new snapshot package available which requires to be installed.'