Hi,
I’m currently trying to figure out a way to export an InstallFile from an already installed and configured Host with Icinga for Windows in a non-interactive way. I can export via the IMC but, that’s interactive. The function responsible for the export seems to be Export-IcingaForWindowsManagementConsoleInstallationAnswerFile ( icinga-powershell-framework/lib/core/installer/menu/installation/general/InstallationAnswerFile.psm1 at 854ef78f919b4a09f6a75f61a7e7ad8d9fba6a6d · Icinga/icinga-powershell-framework · GitHub ) but it is not callable outside the IMC as I cannot pass any parameters.
The idea is to export the configuration to compare it to a predefined standard. If both are equal, the system is in the correct state. If both differ, the predefined configuration is applied. I know that this only captures the stored configuration not the running one, for example the agent might be modified outside the IMC.
But comparing all the config files seems to be a tedious task. Also deploying without the IMC seems to be a problem in its own as so many workarounds are applied in addition to writing config files ( icinga-powershell-framework/lib/core/installer/Start-IcingaForWindowsInstallation.psm1 at 854ef78f919b4a09f6a75f61a7e7ad8d9fba6a6d · Icinga/icinga-powershell-framework · GitHub )
So basically: Is there a way to call `Export-IcingaForWindowsManagementConsoleInstallationAnswerFile in a non interactive way?
Thanks
jonaschl
I am not entirely sure. I will try again with:
Use-Icinga;
Export-IcingaForWindowsManagementConsoleInstallationAnswerFile;
and
Invoke-IcingaCommand { Export-IcingaForWindowsManagementConsoleInstallationAnswerFile }
cstein
(Lord Hepipud)
November 12, 2025, 11:35am
4
Hello
Thank you for the question. Right now there is no native way to export the current configuration with CLI, but it sounds interesting enough to add it.
For now you can write a custom code to export it:
# Load Icinga for Windows
Use-Icinga;
# Define out directory to export the answer file to
[string]$ExportPath = 'C:\Users\Public\';
# Check if our installer flag is present
if ($Global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) {
$Global:Icinga.Add(
'InstallWizard',
@{
'Config' = @{ };
'LastParent' = [System.Collections.ArrayList]@();
}
);
} else {
$Global:Icinga.InstallWizard.Config = @{ };
$Global:Icinga.InstallWizard.LastParent.Clear() | Out-Null;
}
# Read the current stored configuration
$SwapConfig = Get-IcingaPowerShellConfig -Path 'Framework.Config.Swap';
# Convert our config object to a valid JSON-String
$Global:Icinga.InstallWizard.Config = Convert-IcingaForwindowsManagementConsoleJSONConfig -Config $SwapConfig;
# Write the configuration as answer file to disk
Write-IcingaFileSecure -File (Join-Path -Path $ExportPath -ChildPath 'IfW_answer.json') -Value (Get-IcingaForWindowsManagementConsoleConfigurationString);
# Cleanup
$Global:Icinga.Remove('InstallWizard');
For the record, both fail with an error. The path argument inside the Export-IcingaForWindowsManagementConsoleInstallationAnswerFile; is empty, and so Test-Path complains about it. The line is: icinga-powershell-framework/lib/core/installer/menu/installation/general/InstallationAnswerFile.psm1 at 854ef78f919b4a09f6a75f61a7e7ad8d9fba6a6d · Icinga/icinga-powershell-framework · GitHub
Hi,
Thanks for the response and possible solution. I will try it out and come back afterwards.
May I ask another question: the Install-Icinga function is idempotent? So I can call it multiple times with se same answer file and it will not change something unless there is a change to make? Alternatively it configures only the same settings again and does break something either?
Thanks
jonaschl.