if((Get-IcingaAgentInstallerAnswerInput-Prompt'Do you want to use a different package source then "https://packages.icinga.com/windows/"?'-Default'n').result-eq0){
$AgentVersion=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify the version you wish to install ("latest", "snapshot", or a version like "2.11.0")'-Default'v'-DefaultInput'latest').answer;
if((Get-IcingaAgentInstallerAnswerInput-Prompt'The Icinga 2 Agent is already installed. Would you like to update it?'-Default'y').result-eq1){
$UpdateAgent=1;
}else{
$UpdateAgent=0;
}
$InstallerArguments+="-UpdateAgent $UpdateAgent";
}
if($UpdateAgent-eq1){
if([string]::IsNullOrEmpty($AgentVersion)){
$AgentVersion=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify the version you wish to install ("latest", "snapshot", or a version like "2.11.0")'-Default'v').answer;
Write-Host([string]::Format('Updating/Downgrading Icinga 2 Agent to version: "{0}"',$AgentVersion));
}
if([string]::IsNullOrEmpty($PackageSource)){
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Do you want to use a different package source then "https://packages.icinga.com/windows/" ?'-Default'n').result-eq0){
$PackageSource=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify your package source'-Default'v').answer;
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Will this Agent connect to its parent endpoint(s)?'-Default'y').result-eq1){
$InstallerArguments+="-AcceptConnections 1";
$AcceptConnections=1;
}else{
$InstallerArguments+="-AcceptConnections 0";
$AcceptConnections=0;
}
}
if($Endpoints.Count-eq0){
$ArrayString=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify all endpoints this Agent will report to (separated by ",")'-Default'v').answer;
$ArrayString=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify the network destinations this agent will connect to, separated by ","'-Default'v'-DefaultInput$NetworkDefault).answer;
$ParentZone=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please specify the parent zone this agent will connect to'-Default'v'-DefaultInput'master').answer;
$CAEndpoint=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please enter the FQDN for either ONE of your Icinga parent node/nodes or your Icinga 2 CA master'-Default'v'-DefaultInput$Endpoints[0]).answer;
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Is your public Icinga 2 CA (ca.crt) available on a local, network or web share?'-Default'y').result-eq1){
$CAFile=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please provide the full path to your ca.crt file'-Default'v').answer;
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Do you want to change the user the Icinga Agent service is running with (Default: "NT Authority\NetworkService")?'-Default'n').result-eq0){
$ServiceUser=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please enter the user you wish the Icinga Agent service to run with'-Default'v').answer;
$InstallerArguments+="-ServiceUser $ServiceUser";
if($null-eq$ServicePass){
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Does your Icinga Service user require a password to login (not required for System users)?'-Default'y').result-eq1){
$ServicePass=(Get-IcingaAgentInstallerAnswerInput-Prompt'Please enter the password for your service user'-Secure-Default'v').answer;
Write-Host'The wizard is complete. These are the configured settings:';
Write-Host($InstallerArguments|Out-String);
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Is this configuration correct?'-Default'y').result-eq1){
if((Get-IcingaAgentInstallerAnswerInput-Prompt'Do you want to run the installer now? (Otherwise only the configration command will be printed)'-Default'y').result-eq1){
Write-Host'To execute your Icinga Agent installation based on your answers again on this or another machine, simply run this command:'
$RunInstaller=$TRUE;
}else{
Write-Host'To execute your Icinga Agent installation based on your answers, simply run this command:'
}
}else{
Write-Host'Please run the wizard again to modify your answers or modify the command below:'